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 (최근 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));

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by