Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: ode 45 solver problems

Subject: ode 45 solver problems

From: Ender

Date: 25 Jun, 2008 15:04:02

Message: 1 of 3

I cannot see the results from the ode45 solver program
that I wrote. I tried using the plot(T,Y(:,1),'-o')
function from the ode45 help menu but nothing helps.

I then copied the example from "Example 2"the help screen
under ode45. This is what the code says:

function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1)

[T,Y] = ode15s(@vdp1000,[0 1],[2 0]);
plot(T,Y(:,1),'-o')

Whenever I run this code I get error:

??? Input argument "y" is undefined.

Error in ==> vdp1000 at 7
dy(1) = y(2);


I don't understand why this code doesn't work. How do I
see the results from the solver?


Subject: ode 45 solver problems

From: vedenev

Date: 25 Jun, 2008 15:13:31

Message: 2 of 3

Try to make this part of code
function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1)

in separate file with name vdp1000.m

------------------------------------
Maxim Vedenev, Matlab freelancer
http://simulations.narod.ru/

Subject: ode 45 solver problems

From: Steven Lord

Date: 25 Jun, 2008 15:29:09

Message: 3 of 3


"Ender " <jr147@msstate.edu> wrote in message
news:g3tmp2$klb$1@fred.mathworks.com...
>I cannot see the results from the ode45 solver program
> that I wrote. I tried using the plot(T,Y(:,1),'-o')
> function from the ode45 help menu but nothing helps.
>
> I then copied the example from "Example 2"the help screen
> under ode45. This is what the code says:
>
> function dy = vdp1000(t,y)
> dy = zeros(2,1); % a column vector
> dy(1) = y(2);
> dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1)

I'm betting that your vpd1000.m function doesn't end here, but includes the
following two lines. Those two lines should be in a separate file, a
separate function, or typed at the command line.

> [T,Y] = ode15s(@vdp1000,[0 1],[2 0]);
> plot(T,Y(:,1),'-o')
>
> Whenever I run this code I get error:
>
> ??? Input argument "y" is undefined.

Yes, because you're likely calling vdp1000 with 0 input arguments; then on
line 7, where the function tries to use the second element of the second
input, that input doesn't exist.

Even if you were to call vdp1000 (the version with the ODE15S call included)
with two input arguments, when it reached the line where it calls ODE15S,
that function would call VDP1000, which would call ODE15S, which would call
VDP1000, ... and soon you hit the recursion limit. Unless you've written
your code to include a way to end the recursion (or you _want_ an "infinite"
recursion), you shouldn't use a recursive call for that application.

--
Steve Lord
slord@mathworks.com


Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
ode 45 solver Ender 25 Jun, 2008 11:10:21
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics