Create a vector of strings

4 ビュー (過去 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 Center および File ExchangeNumeric Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by