Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Index exceeds matrix Dimensions?
Date: Tue, 27 Mar 2012 17:45:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <jksubh$kth$1@newscl01ah.mathworks.com>
References: <jkshid$42c$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1332870321 21425 172.30.248.45 (27 Mar 2012 17:45:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Mar 2012 17:45:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:762352

"Sanaa" wrote in message <jkshid$42c$1@newscl01ah.mathworks.com>...
> ......
>   n= 200;
> ru = (3.0/n):(3.0/n):4;
> for m = 1:3*n
>       x(m)=bifurcationthird(m/3,ru(m));
> end
>......
- - - - - - - - -
  In the line

 ru = (3.0/n):(3.0/n):4;

you generate the array 'ru' containing only 266 elements, but the index m in the for-loop gets as high as m = 600.  There is no 600th element of 'ru'.  I think you may have meant to have ru = 4/(3*n):4/(3*n):4.

  You should realize that binary floating point numbers, which are what matlab uses for 'double', cannot represent 1/3 exactly, and that means that you are "skating on thin ice" when you write your code as you have.  For example if you were to add up 1/3 six times and then multiply the sum by three, you would not get an exact six for an answer due to round off errors.

Roger Stafford