Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!newsfeed.stanford.edu!newsfeed.news.ucla.edu!nrc-news.nrc.ca!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: Sat, 18 Aug 2007 16:38:59 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 46
Message-ID: <fa77b3$3pt$1@canopus.cc.umanitoba.ca>
References: <f9f08u$qqp$1@fred.mathworks.com> <fa61hd$so$1@fred.mathworks.com> <fa64gs$d9m$1@canopus.cc.umanitoba.ca> <fa6c94$70h$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1187455139 3901 192.70.172.160 (18 Aug 2007 16:38:59 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Sat, 18 Aug 2007 16:38:59 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:424408


In article <fa6c94$70h$1@fred.mathworks.com>,
huda nawaf <halmamory@yahoo.com> wrote:
>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in 
>message <fa64gs$d9m$1@canopus.cc.umanitoba.ca>...

>> %code using try/catch instead:
>> try
>>   for K =1:N
>>     do_something;
>>     if some_variable == 0 then error('Opps0') end;
>>     do_something_more;
>>   end
>>   return
>> catch
>>   if lasterror == 'Opps0'
>>     sprintf('Zero encountered at iteration %d\n', K);
>>     return
>>   else
>>     rethrow(lasterror)
>>   end
>> end

>hi Roberson,

"Roberson" is my family name, not my personal name.


>When I running this example . The following message error 
>appeared:
>??? Error: File: e:\MATLAB6p5\work\us.m Line: 4 Column: 29
>Missing operator, comma, or semicolon.

You weren't meant to literally run it! It was an outline, nothing more!!

But the problem was that I've been using other programming
languages lately, so I accidently used 'then' instead of the Matlab
equivilent structure:

  if some_variable == 0, error('Opps0'), end
or
  if some_variable == 0
    error('Opps0')
  end

-- 
Programming is what happens while you're busy making other plans.