Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: fractional loop Date: Tue, 20 Mar 2012 20:55:16 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 38 Message-ID: <jkaqrk$dqg$1@newscl01ah.mathworks.com> References: <jkajf8$h28$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-02-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1332276916 14160 172.30.248.47 (20 Mar 2012 20:55:16 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Tue, 20 Mar 2012 20:55:16 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:761646 "Sanaa" wrote in message <jkajf8$h28$1@newscl01ah.mathworks.com>... > Greetings, > I am having a problem with the fraction iteration in Matlab. Actually, I have this code to plot the trajectory of the following map > > x_n = -0.5 x_(n-1)+1, x0 = 0, n = 1,2,3,...... > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > clear; > x0=0; > x(1) = x0; > itermax = 50; > for i = 1:itermax-1 > %x(1)= x0; > x(i+1) = - 0.5*x(i)+1; > end > hold off; > plot(x,'r*'); > hold on; > plot(x,'y'); > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > The problem???? > > Now I want to do the same for this problem > x_n = -0.5 x_(n-1/2) + 1, x0 = 0 > n = 1/2, 1, 3/2, 2, ... > > n here is a fraction!!!! > > Any help will be appreciated. - - - - - - - - - This latter definition of x will give you the same sequence of values as the first one. Just define y(m) = x((m-1)/2) for m = 1, 2, 3, ... Then y(1) = x(0) = 0 and y(m+1) = x(m/2) = -.5*x(m/2-1/2)+1 = -.5*y(m)+1 . This shows that y, the second x, and the previous x, all have the same sequence of values. Why is this a problem for you? As you must be aware, matlab will only accept arrays that are indexed by positive integers, so a revised definition like this from x to y is necessary to represent such a sequence as an array in matlab. Roger Stafford