Plot doesn't show in figure
2 views (last 30 days)
Show older comments
Hello,
For my study I need to learn to work with MatLab and we just started using for loop. Now I tried making a diagram with volume at the x-axis and pressure at the y-axis, using XSteam.
T_iso=[400, 600, 800] %vector with isotherms
for T=T_iso
for i = (1:1:15) %assignment told to use i for pressure (pressure in MPa)
v=XSteam('v_pT', i, T) %calculating v, using XSteam
end
plot(v,i) %trying to plot
end
Everything goes well, until I try to plot this. I do get a figure window with the right values on both the axes, but it does not show any lines or something. Does anyone know how to solve this? Thanks a lot!
Sabine
0 Comments
Answers (1)
Stephen23
on 16 Dec 2016
Edited: Stephen23
on 16 Dec 2016
The plot does not show anything because you are not actually plotting anything. You need to use indexing in the loop to store the values that are being calculated, otherwise they will simply get overwritten, and when you go to plot there is nothing to plot. Try this:
I_vec = 1:15;
T_iso = [400,600,800]; % isotherms
% preallocate output matrix:
out = NaN(numel(I_vec),numel(T_iso));
% loop over input vectors:
for ix = 1:numel(I_vec)
for tx = 1:numel(T_iso)
out(ix,tx) = XSteam('v_pT', I_vec(ix), T_iso(tx));
end
end
%
plot(out)
0 Comments
See Also
Categories
Find more on Annotations 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!