Hi everyone,
Im trying to solve a system of 4 1st order differential equations using ode45, ode23s and using euler method,
Starting off with ode45, I have a function called solvede and im trying to use that with my main script file to model the behaviour of xdot over 10 seconds - but I still havent been able to run the model correctly
If you could spot why the code won't work Id appreciate any input
> my code is:
The function>>
function xdot = solvede(x, t)
a = 1.33;
b = 0.5*cos(x(1) - x(3));
c = 0.5*sin(x(1) - x(3))*x(3)^2 + 73.575*sin(x(1));
d = 0.5*cos(x(1) - x(3));
e = 0.333;
f = 24.525*sin(x(3));
xdot(1) = x(2);
xdot(2) = ((b*f - c*e)/(a*e - b*d));
xdot(3) = x(4);
xdot(4) = ((f*a - c*d)/(b*d - e*a));
return
The main scipt file that calls the function:
%Setting up time range
tspan(1) = 0;
tspan(2) = 10;
%Setting up initial conditions
x = [pi 0 pi 0];
%Calling ODE solver
[xdot,t] = ode45(@solvede,tspan,x);


LinkBack URL
About LinkBacks