Path: news.mathworks.com!not-for-mail
From: "huda nawaf" <halmamory@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: go to statment in matlab
Date: Sat, 18 Aug 2007 08:57:08 +0000 (UTC)
Organization: Babylon
Lines: 73
Message-ID: <fa6c94$70h$1@fred.mathworks.com>
References: <f9f08u$qqp$1@fred.mathworks.com> <f9f180$f8j$1@fred.mathworks.com> <f9fm8n$7g1$1@canopus.cc.umanitoba.ca> <fa61hd$so$1@fred.mathworks.com> <fa64gs$d9m$1@canopus.cc.umanitoba.ca>
Reply-To: "huda nawaf" <halmamory@yahoo.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187427428 7185 172.30.248.37 (18 Aug 2007 08:57:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 18 Aug 2007 08:57:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1077087
Xref: news.mathworks.com comp.soft-sys.matlab:424389


roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in 
message <fa64gs$d9m$1@canopus.cc.umanitoba.ca>...
> In article <fa61hd$so$1@fred.mathworks.com>,
> huda nawaf <halmamory@yahoo.com> wrote:
> >roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in 
> >message <f9fm8n$7g1$1@canopus.cc.umanitoba.ca>...
> >> In article <f9f180$f8j$1@fred.mathworks.com>, us  
> ><us@neurol.unizh.ch> wrote:
> >> >huda nawaf:
> >> ><SNIP stubborn...
> 
> >> >> how I can use go to statment in matlab?
> 
> >> >the <goto> statement does not exist in ML...
> 
> >> *Some* uses of goto can be replaced by try/catch 
blocks 
> >> catching custom error() conditions. 
> 
> >hi us,
> 
> 'us' was the person who mentioned that goto does not 
exist.
> The person you are replying to, who mentioned try and 
catch,
> is 'Walter'.
> 
> >please I don't know how can use it (try and catch)
> >please give me example .
> 
> 
> %code as it would be if GO TO existed:
> for K = 1:N
>   do_something;
>   if some_variable == 0, GO TO Opps0, end;
>   do_something_more;
> end
> return
> 
> Opps0:
> sprintf('Zero encountered at iteration %d\n', K);
> return
> 
> 
> %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
> -- 
>    "No one has the right to destroy another person's 
belief by
>    demanding empirical evidence."              -- Ann 
Landers
hi Roberson,
thanks ,
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.