how can i solve this problem related to pssh?

function xd=pssh(t,c)
k1=10^(-8);
k2=10^(-16);
k3=5*10^(-10);
k4=10^(-11);
r1=k1*c(1,:);
r2=k2*c(1,:)*c(3,:);
r3=k3*c(3,:);
r4=k4*c(3,:);
rm=r1+r2-r3-r4;
rh=-r1-r2+r3;
rd=-r4;
xd(1,:)=rh;
xd(2,:)=rd;
xd(3,:)=rm;
end
ic=[10^9];
tspan=[0 25000];
[t,c]=ode45('pssh',tspan,ic)

1 Kommentar

John D'Errico
John D'Errico am 27 Sep. 2017
What problem? What is wrong with what you wrote? Must we read your mind? If you think there is a problem in that, then tell us why you think so. If you have a plot, show it. Help those who you are asking to help you.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 27 Sep. 2017

0 Stimmen

One problem is that the number of initial conditions needs to equal the number of derivatives you are integrating. I set ‘ic’ to be the correct size, you need to provide the correct values.
This works (in R2017b):
function xd=pssh(t,c)
k1=1E-8;
k2=1E-16;
k3=5E-10;
k4=1E-11;
r1=k1*c(1);
r2=k2*c(1).*c(3);
r3=k3*c(3);
r4=k4*c(3);
rm=r1+r2-r3-r4;
rh=-r1-r2+r3;
rd=-r4;
xd(1,:)=rh;
xd(2,:)=rd;
xd(3,:)=rm;
end
ic= [1 1 1]*1E+9;
tspan=[0 25000];
[t,c]=ode45(@pssh,tspan,ic);
figure(1)
plot(t, c)
grid

1 Kommentar

Notice also that Star Strider switched to @pssh from 'pssh' . In the situation where you use a string representing a function name, then that function must have an .m file named after it: that case is not able to find functions that are defined in the same file as the ode* call. The @ version on the other hand is able to handle functions defined in the same file as the ode* call.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Tags

Noch keine Tags eingegeben.

Gefragt:

am 27 Sep. 2017

Kommentiert:

am 28 Sep. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by