saving data when looping
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Mario Malic
el 23 de Nov. de 2020
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 comentarios
Mario Malic
el 23 de Nov. de 2020
I haven't worked with timetable before. Probably, you need to initialise t as a timetable, and use dot indexing to change its values.
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

