MATLAB, Differential Equations help

In summary, the conversation is about a user who is new to MATLAB and is having trouble with an ODE (ordinary differential equation) problem. They share their code for their function file and main program, but they are receiving errors. They also mention a template that was given to help them out. The other person suggests writing out the system of first order ODEs and looking for example files within MATLAB for help.
  • #1
btbam91
91
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
  • #2
No luck? :(
 
  • #3
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
 

1. What is MATLAB and how is it used in differential equations?

MATLAB is a high-performance software used for numerical computation, data analysis, and visualization. It has built-in tools and functions for solving differential equations, making it a popular choice for scientists and engineers.

2. What are differential equations and why are they important?

Differential equations are mathematical equations that describe the relationship between a function and its derivatives. They are important because they are used to model complex systems and phenomena in various fields, such as physics, engineering, and biology.

3. How can MATLAB help with solving differential equations?

MATLAB has a variety of functions and tools for solving differential equations, including ODE solvers, boundary value problem solvers, and partial differential equation solvers. It also has a user-friendly interface for creating and manipulating equations and their solutions.

4. Can MATLAB handle all types of differential equations?

No, MATLAB has certain limitations and may not be able to solve all types of differential equations. It is best suited for linear and non-linear ordinary differential equations and can also handle some partial differential equations.

5. Do I need to have programming experience to use MATLAB for differential equations?

While some basic programming knowledge can be helpful, it is not necessary to have extensive programming experience to use MATLAB for solving differential equations. The software has a user-friendly interface and many built-in functions that can be easily used without prior programming knowledge.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • Calculus and Beyond Homework Help
Replies
5
Views
11K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top