Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

Topic: Getting an error: Attempted to access u(2); index out of bounds because numel(u)=1. Error in ==> treat at 31 if (u(2)>1000)
Replies: 1   Last Post: Feb 12, 2013 11:39 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: Getting an error: Attempted to access u(2); index out of bounds because numel(u)=1. Error in ==> treat at 31 if (u(2)>1000)
Posted: Feb 12, 2013 11:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"gati " <gatimishrano@yahoo.com> wrote in message
news:kfdpbl$ke1$1@newscl01ah.mathworks.com...
> HI, I am using an ode function having three differntial equations in u(1),
> u(2), (3) using function f=treat(t, u), Now when i use if function as if
> (u(2)>1000) c=1; else (u(1)<=100) c=0; end i am getting the following
> error Attempted to access u(2); index out of bounds because numel(u)=1.
> Error in ==> treat at 31 if (u(2)>1000) Please tell me. thanks


My guess is that the initial condition vector you passed into the ODE solver
has only 1 element. If you've got three ODEs in three variables, you need a
3-element initial condition vector.

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




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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.