saving data when looping
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to save each data point in a table t while looping, but I always get the last data point which is 2012!
=
0 件のコメント
回答 (1 件)
Mario Malic
2020 年 11 月 23 日
Because your t accepts only a scalar and it gets overwritten every single time.
% Before loop
n = 1;
t = zeros(1,length(1977:2012));
for i
t(n) = monthYear...
n = n + 1;
end
2 件のコメント
Mario Malic
2020 年 11 月 23 日
I haven't worked with timetable before. Probably, you need to initialise t as a timetable, and use dot indexing to change its values.
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!