How to plot a 2D graph using all the for loop values؟

1 回表示 (過去 30 日間)
Mostafa Shehab
Mostafa Shehab 2015 年 7 月 31 日
コメント済み: Walter Roberson 2015 年 8 月 2 日
clc,clear
xi=input('The solution gas-oil ratio(Rsb)\n');
yi=input( ' The specific gravity of separator gas\n');
Ti=input('reservoir temperature\n');
pi=input('reservoire pressure\n');
zi=input('API of stock tank\n');
Xi=(.013098*Ti^.282372)-(8.2*10^-6*zi^2.176124);
pb=1091.47*(xi^.081465*yi^-.161488*10^Xi-.740152)^5.35489;
fprintf('%s\n%d\n','pb',pb);
fprintf('%4s%15s%20s\n','pi','Co','D');
for ni=1000:1000:10000
n=0;
pi=n+ni;
if pi>=pb
RS=xi;
Co=(-1433+5*xi+2.902*Ti+1.327*yi+12.61*zi)/(10^5*pi);
Apo=52.8-0.01*xi;
for ki=1:100
Aa=-49.893+85.0149*yi-3.70373*yi*Apo+.0479*yi*Apo^2+2.98914*Apo-0.035688*Apo^2;
bpo=(xi*yi+4600*zi)/(73.71+(xi*yi/Aa));
end
Ci=bpo+(.167+16.181*(10^(-0.0425*bpo)))*(pi/1000)-.01*(.299+263*(10^(-0.0603*bpo)))*(pi/1000)^2;
zai=Ci-(0.00302+1.505*Ci^-.951)*(Ti-60)^.938+(.0233*(10^-0.0161*Ci))*(Ti-60)^.475;
fprintf('%4d %15d%20d\n',pi,Co,zai);
end
end
plot(p,Co);
  3 件のコメント
Mostafa Shehab
Mostafa Shehab 2015 年 8 月 2 日
it only plot one point not all loop points
Walter Roberson
Walter Roberson 2015 年 8 月 2 日
A sample of what you would like the plot to look like would be useful. But you can fix the problem about only plotting one point by making the change I showed in my Answer.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 1 日
nvals = 1000:1000:10000;
for nidx = 1 : length(nvals)
n = nvals(nidx);
......
Co(nidx) = (-1433+5*xi+2.902*Ti+1.327*yi+12.61*zi)/(10^5*pi);
...
end
By the way, it is quite confusing for readers when you use "pi" as a variable instead of leaving it as the default constant 3.1415926 (etc)
  2 件のコメント
Mostafa Shehab
Mostafa Shehab 2015 年 8 月 2 日
I'd like to know how get output as vector in for loop in general
Walter Roberson
Walter Roberson 2015 年 8 月 2 日
Follow the framework I gave here: create a vector of the input values, loop over the possible indices of the vector, pull out a particular input value from the vector by its index, store the output indexed by your counter.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractions, Camera Views, and Lighting についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by