Why does char give me an empty output?
조회 수: 5 (최근 30일)
이전 댓글 표시
>> 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
댓글 수: 0
채택된 답변
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개)
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.
C.J. Harris
2015년 9월 21일
This is because ASCII characters 1 to 7 are not visible characters.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!