Only saving last run for loop

1 vue (au cours des 30 derniers jours)
Alexander Garber
Alexander Garber le 11 Avr 2021
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 commentaires
Stephen23
Stephen23 le 12 Avr 2021
Modifié(e) : Stephen23 le 12 Avr 2021
Alexander Garber
Alexander Garber le 12 Avr 2021
ok i will check it out, thanks!!

Connectez-vous pour commenter.

Réponse acceptée

David Hill
David Hill le 11 Avr 2021
pie(1)=0;
for i=1: 560;
z=z+dz;
pie(i+1)=pie(i)-((g/(cp*thetav(z)))*z);
end
  1 commentaire
Alexander Garber
Alexander Garber le 11 Avr 2021
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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by