Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem With a Simple For Loop
Date: Sun, 18 Oct 2009 19:21:00 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 24
Message-ID: <hbfpqs$4bp$1@fred.mathworks.com>
References: <hbfofq$9mi$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255893660 4473 172.30.248.35 (18 Oct 2009 19:21:00 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 18 Oct 2009 19:21:00 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:578204


"Ali Moradi" <kimusubi@gmail.com> wrote in message <hbfofq$9mi$1@fred.mathworks.com>...
> 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. 

No, length 9 is correct.

> Does anyone have any idea as to why this is happening? 

A simply setting

d(1000)=1

will give 1x1000 vector

Bruno