How to Stop an M File?

17 views (last 30 days)
Mahmoud Rashidi
Mahmoud Rashidi on 10 Mar 2017
Answered: John Chilleri on 10 Mar 2017
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 Comment
John Chilleri
John Chilleri on 10 Mar 2017
Do you mean other than using control + C?

Sign in to comment.

Accepted Answer

John Chilleri
John Chilleri on 10 Mar 2017
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!

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!