Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: ODE45 parameters error
Replies: 7   Last Post: Jun 19, 2013 2:51 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 per sundqvist Posts: 365 Registered: 12/7/04
Re: ODE45 parameters error
Posted: Jan 17, 2005 2:05 AM
 Plain Text Reply

Serdar wrote:
>
>
> I have some problems with additional parameters. Code is something
> like that:
> ...
> ...
> ...
> c=place(At,bt,p)
> tspan=linspace(0.001,3,1000);
> [t,x]=ode45('invert_pen',tspan,x0,[],c(1),c(2),c(3));
>
> When i run this script file i have seen the following error.
>
> -------------------------------------------
> ??? Error using ==> invert_pen
> Too many input arguments.
>
> Error in ==> funfun\private\odearguments at 110
> f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
>
> Error in ==> ode45 at 173
> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
>
> Error in ==> invert_pen_ode at 39
> [t,x]=ode45('invert_pen',tspan,x0,[],c(1),c(2),c(3));
> ------------------------------------------
>
> how can i use these parameters in ode45.
> Please help...

The error is in invert_pen. As it is now it MUST look like:

function ans=invert_pen(t,x,c(1),c(2),c(3))

but why don't use c as a vector? invert_pen(t,x,c)
and [t,x]=ode45('invert_pen',tspan,x0,[],c);

/Per

Date Subject Author
1/16/05 Barjac
1/17/05 Shashank Singh
1/17/05 Titus Edelhofer
1/16/05 Barjac
1/17/05 per sundqvist
6/19/13 Sandip
6/19/13 Torsten

© The Math Forum at NCTM 1994-2018. All Rights Reserved.