Add new double array within cell for each iteration in a for loop

4 ビュー (過去 30 日間)
Rudolf
Rudolf 2021 年 4 月 30 日
コメント済み: Rudolf 2021 年 5 月 2 日
I'm trying to get many values out of an excel sheet.
Is it possible to have a cell variable which gets added one more array of double values for each iteration, and how do i write it?
Outside a for loop i can write:
hourValues{1} = some code;
hourValues{2} = some code;
hourValues{3} = some code;
and i will get a 1x3 cell named hourValues which with some code will contain my 3 arrays of double. But how to write this inside a for loop?

採用された回答

Matt J
Matt J 2021 年 4 月 30 日
hourValues=cell(1,3);
for i=1:3
hourValues{i} = some code;
end
  3 件のコメント
Matt J
Matt J 2021 年 4 月 30 日
text = num2str(i)
Rudolf
Rudolf 2021 年 5 月 2 日
There is something weird with the code i use. No matter how i pass the string it doesn't work, so i will have to open a separate question on that. You've answered my questions Matt J, thank you. :)
string() works by the way, and strangely num2str gave me char. Example, this code:
a = 1;
b = string(a);
c = num2str(a);
returns this:

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by