필터 지우기
필터 지우기

Storing all for-loop results of a specific variable in .mat-file

조회 수: 2 (최근 30일)
Timo Baumann
Timo Baumann 2020년 2월 10일
댓글: Timo Baumann 2020년 2월 11일
Hi guys,
after running my code, I'd like to store all calculated values of variable va in the file "d-va.mat", but when running the code shown below, it keeps overwriting the values and only shows the final result. Putting the "save" outside of the loop only gives me the first result.
_____________________________
%this is just a very easy example
for ta=1:20
a = 3;
va = (ta.*a)*3.6;
save('d-va.mat','va');
end
_____________________________
Would be awesome, if one of you could help me with this issue. It's probably very simple, but I can't figure it out :/
Thank you in advance :)

답변 (1개)

Sindar
Sindar 2020년 2월 10일
Assuming all the produced data can fit in memory:
for ta=1:20
a = 3;
% save each value in an array
va(ta) = (ta.*a)*3.6;
end
save('d-va.mat','va');

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by