尝试实现绘图功能但不显示图形

时间:2016-08-30 02:37:22

标签: matlab plot matlab-figure matlab-guide matlab-compiler

在这个MATLAB代码中,我打算显示一个图表,但它显示了一个空图。

% Proposed Model For Two-Phase Flow Analytical Design Equation for gas
% pipelines
clc
d = 26.75; % diameter in inches 
pie = 3.142; %normal pie
A = (pie *d^2)/4; % Compute for the area
qm = 150; %volume flow rate of mixture
pm = 8; %Density of the mixture
Wm = qm* pm; % mass flow rate of mixture i.e oil and gas
Ho = 0.01; %Liquid Hold up
z = 0.85; % compressibility factor
R = 10.73; % Gas constant 
f = 0.0254; %friction factor
p0 = 150; % Density of oil
T = 580; % Temperature in R degrees
P0 =1700; % 1700psi
L = 63.068; % Length
P1 = 602.7; % 602.7 psia
%Assume
Mg = 9.8;

formule1 = d*A^2*Mg*(1-Ho);
formule2 = f*Wm^2*z*R*T;
formule = formule1/formule2;
exprs1 = (p0*Ho*z*R*T)/Mg*(1-Ho);
express2 = P2^2-P1^2
drop_p =P1-P2
express3 = 2*p0*Ho*z*R*T*drop_p
better_express = express2 + express3
func1 = d/f

solve( (formule*better_express)- func1*log(P2+ exprs1/P1 + exprs1)^2 + L == 0, P2)
figure
plot(drop_p,L,'r:+')

拜托,有人可以帮帮我吗?感谢。

1 个答案:

答案 0 :(得分:0)

在您的代码中:drop_p = P1-P2L = 63.068,因此除非P2是向量,否则您的图表中只会得到一个红色+。像这样(对于P2 = 1):

red_cross

现在,solve行会返回错误,因为它应该与变量上的''一起解决:<​​/ p>

solve( (formule*better_express)- func1*log(P2+ exprs1/P1 + exprs1)^2 + L == 0, 'P2')

但这无论如何都不会影响结果图,因为solve输出未分配给任何变量。