How to convert a vector of integers to a vector of characters?
조회 수: 9 (최근 30일)
이전 댓글 표시
Hi - I have a vector of ints, typically 0/1, like this:
[0 0 0 0 1 0 0 0 0 1]
and I want to get this:
['0' '0' '0' '0' '1' '0' '0' '0' '0' '1']
But I cannot figure it out for the life of me. I'm sure it's simple. Thanks for your time and help.
댓글 수: 0
채택된 답변
James Tursa
2013년 2월 10일
Another method for single digits:
A = [0 0 0 0 1 0 0 0 0 1];
B = char(A+'0');
댓글 수: 0
추가 답변 (3개)
Wayne King
2013년 2월 9일
편집: Wayne King
2013년 2월 9일
A = [0 0 0 0 1 0 0 0 0 1];
B = num2str(A);
Now B is a vector of characters
Azzi Abdelmalek
2013년 2월 9일
편집: Azzi Abdelmalek
2013년 2월 9일
a = [0 0 0 0 1 0 0 0 0 1];
y=arrayfun(@(x) cellstr(num2str(x)),a)
% To get any character
y{4} % for e.g
댓글 수: 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!