Plotting a graph from for loops
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 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 Comments
Star Strider
on 28 Mar 2015
Edited: Star Strider
on 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.
More Answers (0)
See Also
Categories
Find more on Specifying Target for Graphics Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!