must return a column vector

2 vues (au cours des 30 derniers jours)
gnanaguru murugan
gnanaguru murugan le 18 Juin 2021
code:
function dy = phy_ode_1(t,y)
dy = zeros(length(y),1);
const=0.5;
sp=-0.5:0.5:14.5;
top=0;
p_crit=sp+top;
dy=const*(y-p_crit);
end
call fun:
[t,y]=ode45('phy_ode_1',0:0.5:10,35)
i got erro, must return column vector. could you help me?

Réponse acceptée

Alan Stevens
Alan Stevens le 18 Juin 2021
Do you want something like this
sp=-0.5:0.5:14.5;
for i = 1:length(sp)
[t,y(:,i)]=ode45(@(t,y) phy_ode_1(t,y,sp(i)),0:0.5:10,35);
end
plot(t,y)
function dy = phy_ode_1(~,y,sp)
const=0.5;
top=0;
p_crit=sp+top;
dy=const*(y-p_crit);
end
  1 commentaire
gnanaguru murugan
gnanaguru murugan le 18 Juin 2021
Thank you for your reply.
this is another function called recruitment. i have to plot betwwen recruitment and phy_ode_1.
function voltot2 = recruitment(PIP,PEEP,opmin,opmax)
A = 0.0072;
B = 0.0072;
K = 0.15;
voltot2=[];
open=[];
voltot=0;
lung_level_units=9000;
for i=1:length(PIP)
for pressure=PEEP:PIP
for SP = -0.5:0.5:14.5
for TOP = opmin:opmax
if opmin == 0 || opmin == opmax
TOP = opmax;
end
if pressure > (SP+TOP)
volm = A-B*exp(-K*(PIP-SP));
vol = volm*lung_level_units/(1+opmax-opmin);
else
vol = 0;
end
voltot = voltot+vol;
end
end
voltot2(end+1)=voltot;
end
end
call fn:
sp=-0.5:0.5:14.5;
PIP=35;
PEEP=0;
opmin=0;
opmax=0;
for i = 1:length(sp)
[t,y(:,i)]=ode45(@(t,y) phy_ode_1(t,y,sp(i)),0:0.5:10,35);
p=y(:,i);
vol=recruitment(PIP,PEEP,opmin,opmax);
plot(p,vol')
end
I got error vector must be same length. from workspace P=21*1, vol=1*36.
could you help me. Thanks a lot

Connectez-vous pour commenter.

Plus de réponses (1)

gnanaguru murugan
gnanaguru murugan le 18 Juin 2021
Thank you for your reply.
this is another function called recruitment. i have to plot betwwen recruitment and phy_ode_1.
function voltot2 = recruitment(PIP,PEEP,opmin,opmax)
A = 0.0072;
B = 0.0072;
K = 0.15;
voltot2=[];
open=[];
voltot=0;
lung_level_units=9000;
for i=1:length(PIP)
for pressure=PEEP:PIP
for SP = -0.5:0.5:14.5
for TOP = opmin:opmax
if opmin == 0 || opmin == opmax
TOP = opmax;
end
if pressure > (SP+TOP)
volm = A-B*exp(-K*(PIP-SP));
vol = volm*lung_level_units/(1+opmax-opmin);
else
vol = 0;
end
voltot = voltot+vol;
end
end
voltot2(end+1)=voltot;
end
end
call fn:
sp=-0.5:0.5:14.5;
PIP=35;
PEEP=0;
opmin=0;
opmax=0;
for i = 1:length(sp)
[t,y(:,i)]=ode45(@(t,y) phy_ode_1(t,y,sp(i)),0:0.5:10,35);
p=y(:,i);
vol=recruitment(PIP,PEEP,opmin,opmax);
plot(p,vol')
end
I got error vector must be same length. from workspace P=21*1, vol=1*36.
could you help me. Thanks a lot

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by