How to solve coupled differential equation in matlab using ode45

3.6k Views Asked by At

I have two differential equations: da/dt=a(.3/a^3+.7)^1/2 and dτ/dt=1/a. The initial conditions are t=0; a=1 and τ=0, respectively. How can I solve the equations in Matlab? I need to calculate different values of a, t and τ also plot τ vs a. Thanks.

1

There are 1 best solutions below

4
On

That's quite easy.

First write a function to implement your differential equation and save it with a filename corresponding to the function name:

function dy = my_ode(t,y)
dy(1) = y(1)*(0.3/y(1)^3 + 0.)^(1/2); % a
dy(2) = 1/dy(1); % tau

Then in MATLAB, call the ode45 solver with your function

[t,y] = ode45(@my_ode,[0 10],[1; 0]);

This is the result:

enter image description here