3 views (last 30 days)

Show older comments

Luna
on 30 Dec 2019

Edited: Luna
on 30 Dec 2019

Basically, it can be done as follows with a while block:

some_condition_to_be_fullfilled = 0;

while some_condition_to_be_fullfilled == 0

if something_happened

% do some mathematical stuff

some_condition_to_be_fullfilled = 1;

% or you can use break

break

else

% do some mathematical stuff

some_condition_to_be_fullfilled = 0;

end

end

Guillaume
on 2 Mar 2020

Actually,

if [in, on] == 0

is equivalent to (assuming both in and on are scalar):

if in == 0 && on == 0

but it's likely the OP wouldn't be able to explain why, so Luna's syntax is strongly recommended. Another option would be:

if all([in, on] == 0)

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!