当前位置:   article > 正文

MATLAB中return和break

return causes a normal return to the invoking function or to the keyboard. i

return:

RETURN Return to invoking function.
RETURN causes a return to the invoking function or to the keyboard.
It also terminates the KEYBOARD mode.

Normally functions return when the end of the function is reached.
A RETURN statement can be used to force an early return.

Example
function d = det(A)
if isempty(A)
d = 1;
return
else
...
end

 

break:

BREAK Terminate execution of WHILE or FOR loop.
BREAK terminates the execution of FOR and WHILE loops.
In nested loops, BREAK exits from the innermost loop only.

BREAK is not defined outside of a FOR or WHILE loop.
Use RETURN in this context instead.

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/909214
推荐阅读
  

闽ICP备14008679号