How to end the running of a script in a subfunction?

I use matlab 2014b where the script and function are in different m files. Is it possible to end the running of the script in a function?

 Accepted Answer

error('Rage quitting!')

7 Comments

This is the best way I have seen so far, although I don't want to see the error message.
if the script cooperates it can use try/catch .
However if the script were cooperating then just return a value from the function and have the script detect it and take appropriate action .
In fact, i just want to end the program when the function detects something. And no more running is needed. So try/catch is not what i want. But thanks for your supplement.
quit() can be called from within a program if you want to exit MATLAB completely.
that's totally the end of program...What I mean is to end the code not the matlab. Sorry for my unclear expression.
Then, NO, you cannot do that without seeing the error message -- not unless the program cooperates to try/catch to detect the quit and stop itself nicely.

Sign in to comment.

More Answers (1)

function...
input('just press control + c to stop script')
end

Categories

Asked:

on 3 Dec 2018

Commented:

on 2 Jan 2019

Community Treasure Hunt

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

Start Hunting!