How to convert a string into row vector?
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ammy
am 11 Mär. 2022
Beantwortet: Image Analyst
am 11 Mär. 2022
a = 753;
b= dec2bin(a);
b= '1011110001'
How can I obtain b as a row vector [1 0 1 1 1 1 0 0 0 1]?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 11 Mär. 2022
Please note that the other answers will not include the leading zero if there is one.
You didn't specify if you want leading zero(s) if there are any. You can specify the number of bits in dec2bin if you want. For example this (dec2bin(a, 8)) is what you might do
a = 103;
b = dec2bin(a)-'0' % Does not include leading zeros for an 8 bit number
c = dec2bin(a, 8)-'0' % Does include leading zeros for an 8 bit number
Did you want leading zeros or not?
0 Kommentare
Weitere Antworten (1)
Arif Hoq
am 11 Mär. 2022
try this:
a = 753;
b= dec2bin(a)
% b= '1011110001'
format longG
output=str2double(b)
3 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!