Azzera filtri
Azzera filtri

save instruction

1 visualizzazione (ultimi 30 giorni)
Neeta
Neeta il 12 Mar 2012
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

Risposta accettata

Thomas
Thomas il 12 Mar 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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by