Convert string to a row matrix

2 次查看(过去 30 天)
hay i want to convert a string into a row matrix
wat i have: '01011100100000100001010110010111'
wat i need: [0 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 1 0 0 1 0 1 1 1]

采纳的回答

Walter Roberson
Walter Roberson 2012-7-15
row_matrix = YourString - '0';

更多回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2012-7-16
a= '01011100100000100001010110010111'
b=~isspace(regexprep(a, '0',' '))
  2 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2012-7-17
编辑:Azzi Abdelmalek 2012-7-17
my aswers is only valid for binary. i know it does'nt work for other numbers

请先登录,再进行评论。


khaled DAWOUD
khaled DAWOUD 2012-7-17
编辑:khaled DAWOUD 2012-7-17
a= '01011100100000100001010110010111'
% b is the matrix for the a.
for k=1:1:size(a,2)
b(k)=str2num(a(k));
end

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by