saving data when looping

1 次查看(过去 30 天)
zakary Surprenant
zakary Surprenant 2020-11-22
评论: Mario Malic 2020-11-23
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!
=

回答(1 个)

Mario Malic
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 个评论
zakary Surprenant
zakary Surprenant 2020-11-23
Hey,
Whe i try to run this code;it gives me this error
I tried using table2array but it still did not work, any idea
Mario Malic
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by