saving data when looping

조회 수: 10 (최근 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