I want to combine to plot . Pressure history time not start up versus time and transient and final versus time. cann someone helps me thank you. I want one plot that arrange everything

조회 수: 1 (최근 30일)
R=8.314/32;
T0=2930;
a=(12)/((2.027*10^6)^0.45);
rhoP=1920;
Astar=pi*0.25^2;
k=1.35;
n=0.45;
P0=101325;
P = P0;
%syms P(t)
%at beginning of the integration set initial values for the persistent variables
rp=0.35; %initial port radius
t1=0; %initial time step
rhoO=P/(R*T0); %gas density
rp=min(rp+((a*P^n)*10^-3)*(t1-t1),0.7);
Ab=2*pi*rp*8;%burn area
v0 = 0.1;
dP=@(t,P)Fun(t,P,R,T0,rp,a,n,t1,Ab,rhoP,Astar,k,v0);%@(t,P)(Ab.*a.*P.^n.*(rhoP-rhoO)-P.*Astar.*sqrt(k/(R.*T0)).*(2/(k+1)).^((k+1)/(2.*(k-1)))).*R.*T0./v0;
[t,P]=ode45(dP, [0,0.1],P0);
y = P;
figure(1)
plot(t,y)
xlabel("Time (s)")
ylabel("Chamber Pressure (Pa)")
title("Chamber Pressure vs Time (Start-Up)")
[t,P]=ode45(dP,[0,60],P0); %numerically integrates dP/dt and returns time step and the pressure at that time step
figure(2)
plot(t,y)
xlabel("Time (s)")
ylabel("Chamber Pressure (Pa)")
title("Chamber Pressure vs Time")
function dP = Fun(t,P,R,T0,rp,a,n,t1,rhoP,Astar,k)
rhoO=P/(R*T0); %gas density
if t==0 %at beginning of the integration set initial values for the persistent variables
rp=0.35; %initial port radius
t1=0; %initial time step
end
rp=min(rp+((a*P^n)*10^-3)*(t-t1),0.7);
Ab=2*pi*rp*8;%burn area
if rp>=0.7 %if grain gets exhausted
Ab=0; %burn area =0
end
v0=pi*rp^2*8; %recalculating free volume available in chamber
t1=t;
dP = (Ab.*a.*P.^n.*(rhoP-rhoO)-P.*Astar.*sqrt(k/(R.*T0)).*(2/(k+1)).^((k+1)/(2.*(k-1)))).*R.*T0./v0;
end
Error in HW08A (line 20)
[t,P]=ode45(dP, [0,0.1],P0);
I want to combine to plot . Pressure history time not start up versus time and transient and final versus time. cann someone helps me thank you.
I want one plot that arrange everyting

채택된 답변

Image Analyst
Image Analyst 2019년 11월 3일
To combine plots on one plot with the same scale (units), use hold on
plot(x1, y1)
hold on
plot(x2,y2);
To use different y axes, try plotyy() or yyaxis().

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by