From: John D'Errico on
acamphuis <allard.camphuis(a)gmail.com> wrote in message <1622418795.35939.1271671312435.JavaMail.root(a)gallium.mathforum.org>...
> Hello,
>
> I have a question:
> with what command can i let the function return to the begin of the function?
> for example if a value meets with an if statement, then the function must start over again.
> How can I do this?

If you bothered reading the responses to your questions,
you would have seen that I already gave an answer.
Don't post the same question three times. Do read the
responses.

help while
help continue

John
From: Loren Shure on
In article <hqjrkm$l9l$1(a)fred.mathworks.com>, woodchips(a)rochester.rr.com
says...
> acamphuis <allard.camphuis(a)gmail.com> wrote in message <1622418795.35939.1271671312435.JavaMail.root(a)gallium.mathforum.org>...
> > Hello,
> >
> > I have a question:
> > with what command can i let the function return to the begin of the function?
> > for example if a value meets with an if statement, then the function must start over again.
> > How can I do this?
>
> If you bothered reading the responses to your questions,
> you would have seen that I already gave an answer.
> Don't post the same question three times. Do read the
> responses.
>
> help while
> help continue
>
> John
>
or call the function from itself recursively...

--
Loren
http://blogs.mathworks.com/loren
http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Walter Roberson on
acamphuis wrote:
> anyone?

Answer the questions I posed about the details of how the functionality
should work, and we may be able to find a solution for you.

If you are looking for a simple answer such as "restart_this_function()"
or "GOTO BEGINNING", then you are _NOT_ going to get it: Matlab does not
provide an explicit feature like that. However, if you go through my
questions and tell us _exactly_ how you need the functionality to work,
then we *might* be able to come up with something that suits your purposes.
From: Walter Roberson on
Allard Camphuis wrote:

> I have a question:
> with what command can i let the function return to the begin of the
> function?
> for example if a value meets with an if statement, then the function
> must start over again.
> How can I do this?

If the function must "start over", then if you have changed any of the
calling parameters, should the starting over undo the changes, as if you
had not done anything? If so, then unless you are using a randomizer in
the code, would the second time around not end up restarting just like
the first?

Should the 'start over' also erase any variables you have created? So,
for example, if you have

if ~exist('foo','var')
foo = 17.9;
end

then upon starting over, should foo be removed so that once more it is
non-existent when the test is encountered?

If you had a 'global' statement somewhere in your code, and it
referenced a variable that was not previously known as a global
variable, that would have created the global variable and given it a
default value. When you 'start over' should Matlab know to remove the
global? But if the global already existed, should it leave the global
with whatever value you had set it to in the function, or should it
reset the global variable to the value it had before you started the
function?

'Starting over' isn't so easy to define...