How do I store the changing values of a variable (generated in a for loop) into a single file without overwriting the previous one?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Steve
am 30 Okt. 2019
Kommentiert: Steve
am 30 Okt. 2019
For example:
n = 100;
for ii = 1 : n
areatriangle = .5*((ii/2)*ii);
end
In the case above, I want to store all the outcomes/iterations of areatriangle, not just the last one. How do I do this?
Thanks in advance for your help!
0 Kommentare
Akzeptierte Antwort
Alex Mcaulley
am 30 Okt. 2019
n = 100;
areatriangle = zeros(1,n)
for ii = 1 : n
areatriangle(ii) = .5*((ii/2)*ii);
end
or:
areatriangle = .5/2*(1:n).^2;
7 Kommentare
Alex Mcaulley
am 30 Okt. 2019
Ohhh yes, you need to change the following lines in the last loop:
ThetaInDegrees_a(j,pt) = acosd(CosTheta_a(j,pt));
ThetaInDegrees_b(j,pt) = acosd(CosTheta_b(j,pt));
ThetaInDegrees_c(j,pt) = acosd(CosTheta_c(j,pt));
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Quadratic Programming and Cone Programming 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!