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: go to statment in matlab
Date: Tue, 21 Aug 2007 18:58:30 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 43
Message-ID: <fafckm$mbc$1@canopus.cc.umanitoba.ca>
References: <f9f08u$qqp$1@fred.mathworks.com> <fa6c94$70h$1@fred.mathworks.com> <fa77b3$3pt$1@canopus.cc.umanitoba.ca> <fae87n$651$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1187722710 22892 192.70.172.160 (21 Aug 2007 18:58:30 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Tue, 21 Aug 2007 18:58:30 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:424829


In article <fae87n$651$1@fred.mathworks.com>,
huda nawaf <halmamory@yahoo.com> wrote:

> s=0;
> try for K =1:20
>
>    s=s+1;
> if K == 20
>    error('Opps0')
>  end
>  
> %do_something_more;
> g=10;
> for i=1:10
>     s=s+g;
> 
>end
>end
> return
>catch
>  if lasterror =='Opps0'

if strcmp(lasterror.message,'Opps0')

>
>  return
>  
> rethrow(lasterror)
>end
>end


In my opinion, if you don't have enough programming skills to be able
to debug a minor problem such as that, then you absolutely
positively should not be using try/catch error processing.

I've been programming for 30 years. I think the last time that
I needed a GOTO construct was about 18 years ago, cleaning up
some Fortran code that had been under development by random students
for 20 years.
-- 
   "No one has the right to destroy another person's belief by
   demanding empirical evidence."              -- Ann Landers