How do i display a binary matrix in the command window for a 2D axis plot?

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 5 月 21 日
num2str(YourBinaryMatrix, '%1d ')

5 件のコメント

Yashlin Naidoo
Yashlin Naidoo 2015 年 5 月 21 日
Hi there could you explain to me that function?
S = num2str(YourBinaryMatrix,'%1d ') is effectively the same as
nrows = size(YourBinaryMatrix,1);
S = cell(nrows,1);
for K = 1 : nrows
S{K} = sprintf('%1d ', YourBinaryMatrix(K,:));
end
S = char(S);
num2str() differs from this in that num2str() figures out the maximum width columns will need to be ahead of time and uses format strings adjusted so that the columns will print out nicely lined up. That lining up is not necessary in the simple case of binary values; it would start coming into play if, for example, you had some values that were single digit numbers and other values that were two digit numbers.
Yashlin Naidoo
Yashlin Naidoo 2015 年 5 月 21 日
When i use that function nothing shows up. This is the line for where i display my image ''axis([xmin xmax ymin ymax]);'' ,how would i use your function in this case
Yashlin Naidoo
Yashlin Naidoo 2015 年 5 月 21 日
I just want to show the binary values in the command window to show my image is a binary image,like in the command window 0 and 1 will be displayed to illustrate my image is a binary one.
Yashlin Naidoo
Yashlin Naidoo 2015 年 5 月 21 日
It gives an error "Too many output arguments".

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

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

製品

質問済み:

2015 年 5 月 21 日

編集済み:

2015 年 5 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by