Plotting a graph from for loops
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My script:
for temp=298:10:800
u = (temp+2139.5)/4875;
end
for u=0.5:0.001:0.6025
Tp = 1/3*(1.57-0)*u*6000000*(0.16^3-0.08^3);
end
I want to plot Tp against temp but cannot figure out how to.
0 commentaires
Réponse acceptée
Star Strider
le 28 Mar 2015
You don’t need the for loops, since MATLAB can do the matrix calculations without them:
temp=298:10:800;
u = (temp+2139.5)/4875;
Tp = 1/3*(1.57-0)*u*6000000*(0.16^3-0.08^3);
figure(1)
plot(temp, Tp)
grid
xlabel('temp')
ylabel('Tp')
Does this do what you want?
4 commentaires
Star Strider
le 28 Mar 2015
Modifié(e) : Star Strider
le 28 Mar 2015
I have absolutely no idea what you are doing. Start with a completely new Editor tab, paste my code to it, and with that tab open, click on the green Run button in the Editor toolstrip at the top of the Editor window. That should work.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!