saving data when looping
조회 수: 10 (최근 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!

