Hello all:
I am trying to solve the ODE's:
d2y/dt2=-g+(P-Pa)*Ap
dP/dt=k*P*((1/m) *(dm/dt) – (k/(L+y))*(dy/dt))
dm/dt=(m/V) [q-c*Ao*(Pa/P)^(1/k) * {2*k/(k-1) * P*V/m *(1-(Pa/P)^((k-1)/k))}^0.5
V(y)=Ap*(L+y)
where w,Ao,q,Ap,Pa,k,L,g are all constants. but P(t),m(t), y(t) are functions of t
I wrote the following M-file but it looks like it's not working for the m variable. Is there anyting wrong with code or state space variable?
##############################################
clear;close allglobal Pa;global A;global Wp;global q;global Ao,global c;global L;global k;Pa=101000;d=.05;Wp=7;q=2;Ao=0.01;c=.1;L=0.75;k=1.4;Te=300;A=0.25*pi*d^2;mass=(Pa*L*A)/(287*Te);ticW=200;tf=10;Fs = .1; %sampling rate
Ts = 1/Fs; %sampling time interval
tspan =0:Fs:tf; %sampling period
y0=[0,.0,101000,mass];[t,y]=ode45(@Sample01,tspan,y0,[]); %y[YfreqDomain_d,frequencyRange_d]=positiveFFT(y(:,1),Fs);
subplot(2,2,1);plot(t,y(:,1),'k');subplot(2,2,2);plot(t,y(:,2),'k');subplot(2,2,3);plot(t,y(:,3)/Pa,'k');subplot(2,2,4);plot(t,y(:,4),'k');dlmwrite('tssst',[y]);toc
HERE IS THE FUNCTION OF STATE SPACE
function y_dot=Sample01(t,y)global Pa;global A;global Wp;global q;global Ao,global c;global L;global k;y_dot=zeros(4,1);y_dot(1)=y(2);y_dot(2)=-Wp*9.81/Wp+(y(3)-Pa)*A/Wp;y_dot(3)=y(3)*((k/y(4))*y_dot(4)-(k/(L+y(1)))*y(2));y_dot(4)=y(4)/(L+y(1))*(q-c*Ao*(Pa/y(3))^(1/k)*((2*k/(k-1))*y(3)*(L+y(1))/y(4)*(1-(Pa/y(3))^((k-1)/k)))^0.5);
Best Answer