Path: news.mathworks.com!not-for-mail
From: "Phil Goddard" <philNOSPAM@goddardconsulting.ca>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Beginner's loop
Date: Mon, 26 Oct 2009 01:24:01 +0000 (UTC)
Organization: Goddard Consulting
Lines: 13
Message-ID: <hc2tnh$dl2$1@fred.mathworks.com>
References: <d228bd22-aa0e-4bc6-9a52-1dfbb168aaf5@g31g2000vbr.googlegroups.com>
Reply-To: "Phil Goddard" <philNOSPAM@goddardconsulting.ca>
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 1256520241 13986 172.30.248.35 (26 Oct 2009 01:24:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 26 Oct 2009 01:24:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 26433
Xref: news.mathworks.com comp.soft-sys.matlab:579954


Given your input vector,
>> for i = 1:size(x)
is equivalent to
>> for i = 1:[1 100]
which is equivalent to
>> for i = 1:1

Hence you are only getting one pass through the loop.

Assuming x is always a vector you want
>> for i = 1:length(x)

Phil.