Create a vector of strings
조회 수: 2 (최근 30일)
이전 댓글 표시
I need to convert a vector of doubles 64x1 to strings by converting them to hex values. I tried allocating a cell
x = cell(64,1)
for hh = 1:64
hex_results(hh,:) = dec2hex(results(hh,:));
end
but the error....
??? Conversion to cell from char is not possible.
keeps popping up. Is there a better way to do this?
Thanks
댓글 수: 1
채택된 답변
Jan
2012년 9월 6일
편집: Jan
2012년 9월 6일
x = cell(64, 1);
for hh = 1:64
hex_results{hh} = dec2hex(results(hh,:)); % curly braces!
end
If results is a vector, try this:
Str = sprintf('%x*', results);
CStr = regexp(Str, '*', 'split');
Another idea is to use dex2hex vectorized:
Str = dec2hex(results);
But as far as I remember, this is not documented. If it is, perhaps cellstr() is required to convert the CHAR-matrix.
댓글 수: 0
추가 답변 (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!