How do I store the changing values of a variable (generated in a for loop) into a single file without overwriting the previous one?

3 ビュー (過去 30 日間)
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!

採用された回答

Alex Mcaulley
Alex Mcaulley 2019 年 10 月 30 日
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 件のコメント
Alex Mcaulley
Alex Mcaulley 2019 年 10 月 30 日
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));
Steve
Steve 2019 年 10 月 30 日
Bingo! You're amazing. Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by