error when using horzcat

2 ビュー (過去 30 日間)
mays afif
mays afif 2015 年 1 月 25 日
コメント済み: Star Strider 2015 年 1 月 25 日
Hi for all...
i have error when using horzcat >>> i crate two vectors randomly ( count1=randi(0:1 ,[1,32]); ) and ( count2=randi(0:1 ,[1,32]); ) and i have this vector number ( d0 = dec2bin( 17623,15); ) the problem is : when i using horzcat ( count1,count2,d0) the result appear with some symbols
can anyone help me

採用された回答

Star Strider
Star Strider 2015 年 1 月 25 日
The problem is that the output from dec2bin is a string, so horizcat considers everything a string. The ‘symbols’ you see are therefore ‘d0’. To see all of the variables as a string of [0 1] ‘bits’ (strings in this instance), use num2str:
count1=num2str(randi(0:1 ,[1,32]),'%d');
count2=num2str(randi(0:1 ,[1,32]),'%d');
d0 = dec2bin( 17623,15);
result = horzcat(count1,count2,d0)
  4 件のコメント
mays afif
mays afif 2015 年 1 月 25 日
thank you very much
Star Strider
Star Strider 2015 年 1 月 25 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by