I'm getting an error I don't understand: Error using system_ex (line 2)

I'm getting an error running a script that I don't understand. I've called a function system_ex which reads as:
function xprime] = system_ex(t,x)
xprime(1,1)=(x(2));
xprime(2,1)=)-1.25/3.4*(x(1));
I then attempt to use ODE 45, typing
>> [t,y] = ode45(system_ex,[0,40],[0,3])
This returns the message
Error using system_ex (line 2)
I've saved system_ex.m to My Documents, and changed the current folder window on the side to my documents. I don't know what's going wrong. Please help

 Accepted Answer

function dx=system_ex(t,x)
dx = zeros(2,1);
dx(1,1)=x(2);
dx(2,1)=-1.25/3.4*x(1);
call your function
[t,y]= ode45(@system_ex,[0 40],[0 3])

1 Comment

Thank you, this was extremely helpful. You corrected a dumb mistake on my part.

Sign in to comment.

More Answers (1)

[t,y] = ode45(@system_ex,[0,40],[0,3])

1 Comment

Your answer was also helpful, but it only let me accept one answer. Thanks!

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!