Path: news.mathworks.com!not-for-mail
From: "Ryan " <riley127099@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to use Looping in a numerical computation?
Date: Mon, 20 Sep 2010 03:12:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 13
Message-ID: <i76je4$afp$1@fred.mathworks.com>
References: <i73mrj$4j7$1@fred.mathworks.com> <i73ums$br4$1@fred.mathworks.com> <i7409g$jik$1@fred.mathworks.com> <i74umk$h08$1@fred.mathworks.com>
Reply-To: "Ryan " <riley127099@hotmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1284952324 10745 172.30.248.38 (20 Sep 2010 03:12:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 20 Sep 2010 03:12:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2041587
Xref: news.mathworks.com comp.soft-sys.matlab:671371

"Jason" <mrgone@hotmail.com> wrote in message <i74umk$h08$1@fred.mathworks.com>...
> "Ryan " <riley127099@hotmail.com> wrote in message <i7409g$jik$1@fred.mathworks.com>...
> > By the way, is there a way I can call upon the results of each iteration. The way I've arranged my code depicts x as the 20th result of the iteration. But how can I subtract the 19th iteration result from the 20th? Is there a way to do this?
> > 
> > Thanks again. 
> 
> Inside the for loop, you can always assign the previous result to a new variable before evaluating the new result.  You can then add a conditional statement to just display the difference of the new and previous iterations you want.
> 
> Jason

Thanks Jason,

could you specify how I can go about doing this for more than 2 variables. Essentially, I want to find the absolute value of all the results minus 1.1. Afterwards, I want to subtract each successive iteration from the preceding iteration. So I want to subtract x_20-x_19, x_19-x_18, x_19-x_17. How exactly do I assign different variables to each iteration result. Will I need to drastically alter my coding?