Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: error in while function
Date: Wed, 27 Feb 2008 07:39:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 36
Message-ID: <fq342m$q9v$1@fred.mathworks.com>
References: <6820854.1204093199469.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
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 1204097942 26943 172.30.248.38 (27 Feb 2008 07:39:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 27 Feb 2008 07:39:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:453954


sronggot <istardi@gmail.com> wrote in message 
<6820854.1204093199469.JavaMail.jakarta@nitrogen.mathforum.org>...
> Dear,
> 
> I have problem with my matlab programming, i use while for my iteration 
and after i run my program.. there are message error like this 
> 
> '??? Attempted to access U1(:,1); index out of bounds because numel(U1)
=1.'
> 
> anyone can help me to solve this problem..
> 
> this my simple program :
> 
>  i=1;
>         U1(1)=500;%First guess [W/m2C]
>         while abs((U1(i+1)-U1(i))/U1(i+1))>=0.01
> A_total=Duty*1000/(U1(i)*delta_T)
> i=1+i;
> U1(i)=1/A_total;
> end
> U1final=U1(i)
--------
  Perhaps you should describe in words what you are trying to accomplish 
with your code.  The interior of the while-loop seems to be using elements of 
the U1 vector that haven't yet been defined.  But whether or not that is so, 
you appear to be multiplying each element in U1 by a fixed constant, delta_T/
(Duty*1000), to obtain the value which is to replace the next element without 
regard to whatever value that element might have previously possessed.  This 
gives you a geometric series which continues until you encounter two 
successive values in U1 that differ by less than one percent.  As it stands, it 
does not seem to make a lot of sense, and we are left guessing what it is you 
really had in mind.

Roger Stafford