Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Problem With a Simple For Loop
Date: Sun, 18 Oct 2009 18:58:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 13
Message-ID: <hbfofq$9mi$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255892282 9938 172.30.248.38 (18 Oct 2009 18:58:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 18 Oct 2009 18:58:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1592646
Xref: news.mathworks.com comp.soft-sys.matlab:578199


Hi,

I'm writing a simple for loop for a homework problem and I'm coming across a weird problem that I can't figure out. I have 3 vectors all of size 9x1. I'm doing the following for loop:

for i = 2:9
    dzu(i) = PPZU(i)-PPZU(i-1);
    dzl(i) = PPZL(i)-PPZL(i-1);
    dx(i) = PPX(i)-PPX(i-1);
end

The problem is that when I run it, I get a 9x1 vector as the answer, but it should be a 8x1 vector instead. Does anyone have any idea as to why this is happening? Thank you all in advance for your help.

- Ali