Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to get back to a position in the code

Subject: How to get back to a position in the code

From: Diego Zegarra

Date: 21 Feb, 2009 20:02:02

Message: 1 of 2

Assume the code goes like this,

while ...
      if ... (1)
            if ... (2)

            else
                  break
            end
     end
end

In this code once it reaches the else, then the break makes it leave the while loop, how can I make that line to instead of getting out of the while loop to go back to the if statement (1)??

I know I can add another while statement same as the first but I think it would be nonsense. Like this,

while ...
      if ... (1)
           while ...
                if ... (2)

                else
                     break
                end
            end
     end
end

Subject: How to get back to a position in the code

From: per isakson

Date: 21 Feb, 2009 20:34:02

Message: 2 of 2

"Diego Zegarra" <diegozbb@gmail.com> wrote in message <gnpmjp$k0b$1@fred.mathworks.com>...
> Assume the code goes like this,
>
> while ...
> if ... (1)
> if ... (2)
>
> else
> break
> end
> end
> end
>
> In this code once it reaches the else, then the break makes it leave the while loop, how can I make that line to instead of getting out of the while loop to go back to the if statement (1)??
>
> I know I can add another while statement same as the first but I think it would be nonsense. Like this,
>
> while ...
> if ... (1)
> while ...
> if ... (2)
>
> else
> break
> end
> end
> end
> end

See: continue
/per

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us