Re: Returning within a Number of Functions
- From: LindsE <LindsEHillier@xxxxxxxxx>
- Date: Wed, 17 Sep 2008 07:20:41 -0700 (PDT)
On Sep 10, 4:11 pm, "David " <d...@xxxxxxxxxxxxxx> wrote:
LindsE <LindsEHill...@xxxxxxxxx> wrote in message <b312b9fe-54bf-4e87-a0be-7bc445129...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
On Sep 10, 3:38=A0pm, "David " <d...@xxxxxxxxxxxxxx> wrote:
LindsE <LindsEHill...@xxxxxxxxx> wrote in message <d1b44d0a-5822-4a2d-bd8=5-ca73abd32...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
Hi there;
I have a series of several functions running within a large loop and
would like Matlab to proceed to the next value in the loop if a
certain condition exists.
For example:
I run a calling function that calls about 15 - 20 other functions
within a loop (111 iterations). Within function #12, if a variable =3D
0, I want Matlab to stop the iteration and return to the calling
function taking the next iteration and running until the condition is
met again.
Is there a function that can do this? Right now I'm using:
=A0 =A0 =A0 =A0 warning('Required data may be out of grid''s bounds')
=A0 =A0 =A0 =A0 dbstop if warning
but that won't allow the function to continue with the next
iteration. =A0Is it possible to use a "try"/"catch" such that:
try
=A0value ~=3D0
catch
=A0 return to calling function
end
or something similar?
I hope I have provided ample detail!
Thanks;
Lindsay
how about just
if (value~=3D0)
=A0 return
end
Will 'return' bring me back to the calling function? I tried it
before but perhaps I made a typo as it didn't seem to work.
if i am reading your word description it should... maybe you should cut down some code as an example... what i think you are saying is
function loopfunction()
for x=1:111
callingfunction()
end
function callingfunction()
function1()
function2()
...
a=function12();
if (a~=0)
return
end
...
now it could be that you are calling all the functions right in the loop and just want to skip to the next iteration, that would use the continue function like this:
for x=1:111
function1()
function2()
...
a=function12();
if (a~=0)
continue
end
...
function20()
end
in this case when you hit your condition the continue statement skips to the end of the for loop and does the next iteration.
Hi, David;
The second example is closer, but still not quite it. Let me explain
using your example:
for x=1:111
function1()
function2()
...
a=function12();
if (a~=0)
continue
end
...
function20()
end
Where you use continue and function20() is called, I wish to return to
within the loop and call function1() again as each looped iteration
uses different data but the same functions.
Does this make any sense to you?
Thanks;
Lindsay
.
- References:
- Returning within a Number of Functions
- From: LindsE
- Re: Returning within a Number of Functions
- From: LindsE
- Re: Returning within a Number of Functions
- From: David
- Returning within a Number of Functions
- Prev by Date: Re: 3D circle fitting
- Next by Date: Re: strange news reader changes??
- Previous by thread: Re: Returning within a Number of Functions
- Next by thread: Re: Edit text callback?
- Index(es):
Relevant Pages
|