필터 지우기
필터 지우기

How to Stop an M File?

조회 수: 18 (최근 30일)
Mahmoud Rashidi
Mahmoud Rashidi 2017년 3월 10일
답변: John Chilleri 2017년 3월 10일
I have several functions in an M File:
function myfun1
myfun2
end
function myfun2
myfun3
end
How can I stop executing a specific function and exit the script?
  댓글 수: 1
John Chilleri
John Chilleri 2017년 3월 10일
Do you mean other than using control + C?

댓글을 달려면 로그인하십시오.

채택된 답변

John Chilleri
John Chilleri 2017년 3월 10일
Hello,
You can use return in your script and function to exit.
For example,
function output = blah(input)
if input == 5
output = 1;
return
end
...
end
With a script:
...
output = blah(input)
if output == 1
return
end
...
So in summary, you can use return just as you might in a function.
Hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by