The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Topic: Help with ode45
Replies: 3   Last Post: Oct 17, 2012 9:46 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 374
Registered: 1/3/09
Re: Help with ode45
Posted: Oct 17, 2012 3:43 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Anna Baturin" <> wrote in message <k5ks35$56m$>...
> I am trying to use the ode45 function for dy/dx=sin(y*x^2)
> the function was saved as an m file which I called f
> I have to do it for y0=2 and y0=1 and then plot them.
> When I plot I keep getting the error "vectors must be the smae length"
> Here is my work:
> a=-2
> b=2
> y0=2
> y01=1
> [x,y1]=ode45('f',[a,b],y0)
> [x,y2]=ode45('f',[a,b],y01)
> plot(x,y1,'--k',x,y2)
> then I get the error "vectors muct be the smae length"
> How do I fix this?

try this:

function dy = myfun(x,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = sin(y*x^2);


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

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