From: "Ryan " <>
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$>
References: <i73mrj$4j7$> <i73ums$br4$> <i7409g$jik$> <i74umk$h08$>
Reply-To: "Ryan " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1284952324 10745 (20 Sep 2010 03:12:04 GMT)
NNTP-Posting-Date: Mon, 20 Sep 2010 03:12:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2041587
Xref: comp.soft-sys.matlab:671371

"Jason" <> wrote in message <i74umk$h08$>...
> "Ryan " <> wrote in message <i7409g$jik$>...
> > 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?