フィルターのクリア

Why does char give me an empty output?

11 ビュー (過去 30 日間)
Geri Spinosa
Geri Spinosa 2015 年 9 月 21 日
編集済み: Stephen23 2015 年 9 月 21 日
>> b=[1,2,3,4,5]
b =
1 2 3 4 5
>> char(b)
ans =
this is what I enter and the output is five little empty boxes. I've tried this with several numeric vectors and matrices and it does the same thing with varying numbers of boxes. It also does this if I manually input the vector. It was working previously, and then it wasn't I'm not sure what I'm doing wrong

採用された回答

James Tursa
James Tursa 2015 年 9 月 21 日
編集済み: James Tursa 2015 年 9 月 21 日
Characters for ASCII codes 1, 2, 3, 4, 5 are all unprintable characters, so nothing prints. The conversion did take place, but the result is not printable (displayable). The characters are:
1 01 SOH Start of heading
2 02 STX Start of text
3 03 ETX End of text
4 04 EOT End of trans.
5 05 ENQ Enquiry
  2 件のコメント
Geri Spinosa
Geri Spinosa 2015 年 9 月 21 日
Thank you, that explains it, not sure what I was doing before, but I'll figure it out.
Stephen23
Stephen23 2015 年 9 月 21 日
編集済み: Stephen23 2015 年 9 月 21 日
About halfway down this page are two tables, one with the unprintable and one the printable ASCII characters:

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

その他の回答 (2 件)

Joseph Cheng
Joseph Cheng 2015 年 9 月 21 日
char() converts the values into the 7-bit ASCII characters. use num2str() or the other equivalent functions to convert numbers to a string.
  1 件のコメント
Geri Spinosa
Geri Spinosa 2015 年 9 月 21 日
Well, thank you for answering, but I'm not trying to convert it to a string, I'm just trying to display the elements as a column vector.

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


C.J. Harris
C.J. Harris 2015 年 9 月 21 日
This is because ASCII characters 1 to 7 are not visible characters.
See the 'Dec' column: http://www.asciitable.com/

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by