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!
=

Antworten (1)

Mario Malic
Mario Malic am 23 Nov. 2020

0 Stimmen

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 Kommentare

zakary Surprenant
zakary Surprenant am 23 Nov. 2020
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 am 23 Nov. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 22 Nov. 2020

Kommentiert:

am 23 Nov. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by