PLEASE help : system of ODE

I have system of five differential equations with initial conditions. They are as follows. Kindly help me solve them.
Dx=((((0.4*a)/(a*(0.029*x)))*(0.668/(b+0.668)))-((1/v)*0.01))*x
Da=((0.01/v)*50)-(((((2/5)+(13*0.13)+(3*0.051)+(3*2.62))*(0.01/v))+(3*0.188))*x)-((0.01/v)*a)
Db=(2*(((0.051+(2*(0.13-(1/20)))+2.62)*(0.1/v))+0.188))-((0.01/v)*b)
Dc=((6*(0.13-(1/20)))*(0.01/v))-((0.01/v)*c)
Dv=0.01
the initial conditions are as follows:
x(0)=4.41
a(0)=0
b(0)=22.68
c(0)=1.28
v(0)=1

Answers (1)

Hi,
Based on this article (chapter 2.3)
I think you have to do it like this:
function my_func()
start_cond = [4.41, 0, 22.68, 1.28, 1];
tspan = [0,20];
[t,x] = ode45(@func,tspan,start_cond);
plot(t,x);
function out = func(t,x)
%x(1) is variable x
%x(2) is variable a
%x(3) is variable b
%x(4) is variable c
%x(5) is variable v
out = zeros(size(x));
out(1) = ((((0.4*x(2))/(x(2)*(0.029*x(1))))*(0.668/(x(3)+0.668)))-((1/x(5))*0.01))*x(1);
out(2) = ((0.01/x(5))*50)-(((((2/5)+(13*0.13)+(3*0.051)+(3*2.62))*(0.01/x(5)))+(3*0.188))*x(1))-((0.01/x(5))*x(2));
out(3) = (2*(((0.051+(2*(0.13-(1/20)))+2.62)*(0.1/x(5)))+0.188))-((0.01/x(5))*x(3));
out(4) = ((6*(0.13-(1/20)))*(0.01/x(5)))-((0.01/x(5))*x(4));
out(5) = 0.01;
end
Please double check the code for typos in regard of the x(1,...5) convertion!

4 Comments

Thanks for your reply sir. However ode45 solver helps in finding the function values at a particular time span. Is there any way to get the general solution i.e. I mean the each function's expression as a function of other dependent variables.
Thanks.
When you like to get a closed solution you need the Symbolic Math Toolbox which contains the function dsolve:
http://www.mathworks.com/help/releases/R2011a/toolbox/symbolic/dsolve.html
could you kindly show me how to do it sir?
Acording to the doc I would say like this:
out = dsolve('Dx=((((0.4*a)/(a*(0.029*x)))*(0.668/(b+0.668)))-((1/v)*0.01))*x',...
'Da=((0.01/v)*50)-(((((2/5)+(13*0.13)+(3*0.051)+(3*2.62))*(0.01/v))+(3*0.188))*x)-((0.01/v)*a)',...
'Db=(2*(((0.051+(2*(0.13-(1/20)))+2.62)*(0.1/v))+0.188))-((0.01/v)*b)',...
'Dc=((6*(0.13-(1/20)))*(0.01/v))-((0.01/v)*c)',...
'Dv=0.01','x(0)=4.41','a(0)=0','b(0)=22.68','c(0)=1.28','v(0)=1')
But I get an error which I don't understand. Than I tried it without the initial conditions:
out = dsolve('Dx=((((0.4*a)/(a*(0.029*x)))*(0.668/(b+0.668)))-((1/v)*0.01))*x',...
'Da=((0.01/v)*50)-(((((2/5)+(13*0.13)+(3*0.051)+(3*2.62))*(0.01/v))+(3*0.188))*x)-((0.01/v)*a)',...
'Db=(2*(((0.051+(2*(0.13-(1/20)))+2.62)*(0.1/v))+0.188))-((0.01/v)*b)',...
'Dc=((6*(0.13-(1/20)))*(0.01/v))-((0.01/v)*c)',...
'Dv=0.01')
which worked fine. The result for b,c,v looks good. x and a looking very complicated. You have to calculate the unknown C** variables afterwards. Since you have the initial conditions this should be possible but totally ugly.
Why not using the numerically solution? Its faster and easier to handle.

This question is closed.

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!