error handling - How to exit a matlab m-file (NOT the matlab itself) if the user enters bad inputs? -


If the user enters bad input, then how to get out of a matlab m-file (nor matlab)? I know that if an M-file goes wrong on runtime, then we can press Ctrl-C to stop it. But I need an order to put in my M-file to do this, if something bad happens

Please do not suggest the 'exit' or 'quit' command, because they Finish the entire matlab and I do not want this.

You can just enter an error command like error ('bad user input'), Must stop.

Edit: Alternatively, you simply do not set the input flag to true unless your code refactor if you are valid or input or call your main function Then fprintf ('invalid input') end

  inp = input ('& gt;', s)> 

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -