MATLAB Answers

Only saving last run for loop

40 views (last 30 days)
Alexander Garber
Alexander Garber on 11 Apr 2021 at 22:18
Commented: Alexander Garber on 12 Apr 2021 at 4:48
This is my code
for i=1: 560;
z=z+dz;
pie=pie-((g/(cp*thetav(z)))*z);
end
I need pie for later calculations. The problem is that it only saves the last value of pie, and forgets all the rest. Is there a way to fix this?
Thanks
  3 Comments
Alexander Garber
Alexander Garber on 12 Apr 2021 at 4:48
ok i will check it out, thanks!!

Sign in to comment.

Accepted Answer

David Hill
David Hill on 11 Apr 2021 at 22:40
pie(1)=0;
for i=1: 560;
z=z+dz;
pie(i+1)=pie(i)-((g/(cp*thetav(z)))*z);
end
  1 Comment
Alexander Garber
Alexander Garber on 11 Apr 2021 at 23:02
How would I plot that? My current plot just has many horizontal lines. Is there a way to assign a specific z value for each data point?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by