matrix and binary bits
古いコメントを表示
I have a matrix that I use it like an index, for example: A=[1 3 2 4 1 3] which points to a matrix which represents binary bits B=[00 01 11 10]. How can I produce these bits (like decimal numbers of course) but in a single line matrix (e.g. 0 0 1 1 0 1 1 0 0 0 1 1)? I mean I want: C=B(1) gives me 0 0, C=B(2) gives me 0 1 and so on...
Thank you..
採用された回答
その他の回答 (2 件)
Fangjun Jiang
2011 年 11 月 13 日
B=[00 01 11 10];
C=num2str(B','%02d');
or
i=1;
C=sprintf('%02d',B(i));
2 件のコメント
athpapa -
2011 年 11 月 13 日
Fangjun Jiang
2011 年 11 月 13 日
After the code above, use str2num([C(:)]), or uint8(str2num([C(:)]))
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!