MATLAB, Differential Equations help

btbam91
Messages
91
Reaction score
0
[PLAIN]http://img19.imageshack.us/img19/9946/matlabhelp.png

Alright guys, I am extremely new with MATLAB, and this ODE problem is giving me a hard time.

For my function file, I got


function dy = hode(t,y)
dy = [y(4);
-(3/5)*y(4)-(138/100)*y(3)-(231/500)*y(2)-(2929/10000)*y(1)];
end


And for my mainprogram-odesolver-plot file I got


tspan=[0,100];
init=[2,1,0,0];
[t,y] = ode45(@hode,tspan,init);
plot(t,y,'r')
\


Unfortunately, I keep getting these errors.


? Error using ==> odearguments at 116
HODE returns a vector of length 2, but the length of initial conditions
vector is 4. The vector returned by HODE and the initial conditions
vector must have the same number of elements.

Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn,
...

Error in ==> mainprogram at 3
[t,y] = ode45(@hode,tspan,init);



This template was given to help us out.

[PLAIN]http://img808.imageshack.us/img808/5205/matlabhelp2.png


Thanks for the help!
 
Last edited by a moderator:
Physics news on Phys.org
No luck? :(
 
I would suggest you write out the system of first order ODEs first. There should be example files within MATLAB itself that should help you. What are these equations?

Mat
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...

Similar threads

Back
Top