Create a vector of strings

조회 수: 2 (최근 30일)
William
William 2012년 9월 6일
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
Jan 2012년 9월 6일
편집: Jan 2012년 9월 6일
The allocated cell "x" does not appear again...
What is type and size is "results"?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
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개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by