how to generate a vector of binary code
Show older comments
hello , i want to generate a vector of size 10 of binary code(zeros and ones ) ,any one can help?
Accepted Answer
More Answers (1)
Here you go:
% a numeric vector of length 10, containing zeros and ones:
[zeros(1,4) ones(1,6)]
% a logical vector of length 10, containing 'false's and 'true's:
[false(1,3) true(1,5) false(1,2)]
% a character vector of length 10, containing '0's and '1's
'1010110001'
1 Comment
kurdistan mohsin
on 2 Jul 2022
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!