フィルターのクリア

Convert string to a row matrix

5 ビュー (過去 30 日間)
Sadia
Sadia 2012 年 7 月 15 日
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';
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 7 月 17 日
nice

サインインしてコメントする。

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 7 月 16 日
a= '01011100100000100001010110010111'
b=~isspace(regexprep(a, '0',' '))
  2 件のコメント
Walter Roberson
Walter Roberson 2012 年 7 月 16 日
Clunky :(
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 Center および File ExchangeEncryption / Cryptography についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by