save instruction
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, This is an elementary question related to Matlab Programming. I am using a loop in main body of program and this loop execute 50 times for "x" variable. I would like to save values of "x" in a mat file after each execution. If I am using save ("filename", x) within the loop it saves only last value of the variable "x". Please let me know, can I save each value of "x" in a file (like a vector). Do you think I need to make a data set. Thank you, Neeta
0 Kommentare
Akzeptierte Antwort
Thomas
am 12 Mär. 2012
You would rather do well to save the data in a vector than write a mat file every time the loop runs:
This video should help:
You can save the output in a vector or matrix as shown,
Eg:
for i=1:10
y(i)=i+rand; % use y(i) so that it is written as a vector
end
or you could use:
z=[];
for i=1:10
z=[z i+rand];
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!