Plot doesn't show in figure
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Stephen23
2016 年 12 月 16 日
編集済み: Stephen23
2016 年 12 月 16 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!