Why does char give me an empty output?
13 views (last 30 days)
1 2 3 4 5
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 on 21 Sep 2015
Edited: James Tursa on 21 Sep 2015
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
More Answers (2)
Joseph Cheng on 21 Sep 2015
char() converts the values into the 7-bit ASCII characters. use num2str() or the other equivalent functions to convert numbers to a string.