Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ode45 error (not enough inputs)

Subject: ode45 error (not enough inputs)

From: iam49erfreak

Date: 24 Apr, 2013 21:22:10

Message: 1 of 3

I am trying to solve a system of ODEs and when I follow an example on how to use ode45 I keep getting an error saying that I don't have enough input arguments and that 't' isnt being used. What am I doing wrong? Any help is greatly appreciated!

function dy = rigid(t,y)
dy = zeros(3,1);
dy(1) = (16.38124)*(y(2) - ((y(1))*(y(2))) + y(1) - (.008376*((y(1))^2)));
dy(2) = (.0027436)*(y(3) - y(2) - (x*(y(2))));
dy(3) = (.034132)*(y(1) - y(3));

options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);
[T,Y] = ode45(@rigid,[0 610],[4 1.1 4],options);

plot(T,Y(:,1),'-',T,Y(:,2),'-.',T,Y(:,3),'.')

Subject: ode45 error (not enough inputs)

From: Nasser M. Abbasi

Date: 24 Apr, 2013 23:35:42

Message: 2 of 3

On 4/24/2013 4:22 PM, iam49erfreak wrote:
> I am trying to solve a system of ODEs and when I follow an
>example on how to use ode45 I keep getting an error saying that
>I don't have enough input arguments and that 't' isnt being used.
>What am I doing wrong? Any help is greatly appreciated!
>
> function dy = rigid(t,y)
> dy = zeros(3,1);
> dy(1) = (16.38124)*(y(2) - ((y(1))*(y(2))) + y(1) - (.008376*((y(1))^2)));
> dy(2) = (.0027436)*(y(3) - y(2) - (x*(y(2))));
> dy(3) = (.034132)*(y(1) - y(3));
>
> options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);
> [T,Y] = ode45(@rigid,[0 610],[4 1.1 4],options);
>
> plot(T,Y(:,1),'-',T,Y(:,2),'-.',T,Y(:,3),'.')
>

Why not try ode45 on simple examples first, to learn well,
before you go to more advanced ones?

I do not understand what you have above. Is this all in one
function? or rigid() is in it own function and the rest of
the code is in different function?

Also, just look at the code in rigid(). I see an 'x', where
did this 'x' come from? I see no 'x' defined any where in
the code you have there. In Matlab, if you use a variable
on the RHS of an expression, then it needs to have a numerical
value, unless it is a syms.

------------------------------
EDU>> clear x
EDU>> y=x
Undefined function or variable 'x'.
-----------------------------


--Nasser

Subject: ode45 error (not enough inputs)

From: Steven_Lord

Date: 25 Apr, 2013 01:06:22

Message: 3 of 3



"iam49erfreak " <iam49erfreak@yahoo.com> wrote in message
news:kl9ie2$i0$1@newscl01ah.mathworks.com...
> I am trying to solve a system of ODEs and when I follow an example on how
> to use ode45 I keep getting an error saying that I don't have enough input
> arguments and that 't' isnt being used. What am I doing wrong? Any help is
> greatly appreciated!
>
> function dy = rigid(t,y)
> dy = zeros(3,1);
> dy(1) = (16.38124)*(y(2) - ((y(1))*(y(2))) + y(1) - (.008376*((y(1))^2)));
> dy(2) = (.0027436)*(y(3) - y(2) - (x*(y(2))));
> dy(3) = (.034132)*(y(1) - y(3));
>
> options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);
> [T,Y] = ode45(@rigid,[0 610],[4 1.1 4],options);

Move the ODE45 call with @rigid as its first input OUT of the rigid function
itself. It should be in a separate function or script.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us