how to save data from for loop in a matrix ??
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello;
How i can save all values that i calculated from the for loop in a new matrix , but i have in the last loop one value ??? thanks
0 Commenti
Risposte (2)
KSSV
il 26 Set 2016
It depends on how your code is.
You may see the below example, where I am saving the output into mat file in a loop .
clc; clear all ;
for i = 1:10
x=randn(1,1000);
out(i,:)=x.^2;
if i == 1
filename='myfile.mat';
save(filename,'out','-v7.3'); % save to MAT file
else
save(filename,'out','-append');
end
end
Note that out can be initialized knowing the loop. there are many other ways too to save the output.
Vedere anche
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!