How to plot a 2D graph using all the for loop values؟
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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 个评论
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 Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!