Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: error in while function
Date: Wed, 27 Feb 2008 06:35:47 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 32
Message-ID: <fq30c3$cn7$1@canopus.cc.umanitoba.ca>
References: <6820854.1204093199469.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1204094147 13031 192.70.172.160 (27 Feb 2008 06:35:47 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Wed, 27 Feb 2008 06:35:47 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:453949


In article <6820854.1204093199469.JavaMail.jakarta@nitrogen.mathforum.org>,
sronggot  <istardi@gmail.com> wrote:

>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

i starts at 1, and U1 starts at only one element [U1(1)=500],
and the very first access you make is to U1(i+1) which would be to
U1(2) which does not exist.

>A_total=Duty*1000/(U1(i)*delta_T)
>i=1+i;
>U1(i)=1/A_total;
>end
>U1final=U1(i)


You will have to completely rethink your code; there is no obvious
way to fix it that would not destroy the code structure you have
established.
-- 
  "Is there any thing whereof it may be said, See, this is new? It hath
  been already of old time, which was before us."    -- Ecclesiastes