Asked by Pazzo Giampalo
on 19 Jul 2013

Hello,

I am new to matlab. I was trying to follow an instruction from mit.edu.

I want to use ode45 to solve ODEs.

I have the following in my function page:

function dxy = diffxy (t, xy) x = xy(1); xdot = xy(2); y = xy(3); xdot = xdot; ydot = 3*x+5; xdoubledot = 3-ydot+2*xdot dxy = [xdot; xdoubledot; ydot]

To get a solution, I type [T, XY] ode45 ('diffxy', 0, 10, [0 1 0]) in my command window (t from 0 to 10 and the initial value of x is 0, xdot is 1, and ydot is 0). But the following message :

??? [T, XY] ode45 ('diffxy', 0 10, [0 1 0]) | Error: Unexpected MATLAB expression.

I wonder if anyone could please help.

Thankyou!

Pazzo

*No products are associated with this question.*

Answer by Matt Kindig
on 19 Jul 2013

Did you forget the assignment sign?

[T, XY] = ode45 ('diffxy', 0 10, [0 1 0])

Pazzo Giampalo
on 20 Jul 2013

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 1 Comment

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/82626#comment_160811

What is "my function page"?

I've formatted your code. Please read the "? Help" link to find out, how to do this by your own. Thanks.

You need an additional "=" to assign the output.