Hi,
I have a numeric array and want to concatenate each element with a string. As I will use the new array as a header, it needs to end up as a cell array.
i am trying:
wl_arr = 400:1.85:2400;
hdr = strcat('L_conv_', num2cell(wl_arr));
but get this:
I also tried:
wl_arr_str = num2str(wl_arr);
rad_conv_hdr1 = strcat('L_conv_', wl_arr_str);

3 件のコメント

Walter Roberson
Walter Roberson 2019 年 8 月 30 日
"L_conv_" + wl_arr
Provided you have r2017a or later
Andrew Longmire
Andrew Longmire 2019 年 8 月 30 日
Thanks a lot for speedy answer. However,
The VariableNames property must be a cell array, with each element containing one nonempty character vector.
Walter Roberson
Walter Roberson 2019 年 8 月 30 日
Your code does not use table objects so it is not clear why you have that error.

サインインしてコメントする。

 採用された回答

Bruno Luong
Bruno Luong 2019 年 8 月 30 日

0 投票

hdr = arrayfun(@(x) sprintf('L_conv_%f', x), wl_arr, 'unif', 0)

3 件のコメント

Andrew Longmire
Andrew Longmire 2019 年 8 月 30 日
thanks Bruno.
can i limit the number of dp printed in the header?
Bruno Luong
Bruno Luong 2019 年 8 月 30 日
Play with the format
hdr = arrayfun(@(x) sprintf('L_conv_%3.1f', x), wl_arr, 'unif', 0)
Andrew Longmire
Andrew Longmire 2019 年 8 月 30 日
great thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Data Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by