Return all?

조회 수: 9 (최근 30일)
David
David 2011년 5월 23일
I'm writing a custom input() function that, given the input 'quit', should stop all currently running functions and return to the command prompt. I'm running into an issue where a simple return isn't giving me the results I need, is there some alternative to this?
For example, I am writing a function that allows a user to pick an item from a list. I want my custom input() to immediately check for 'quit', and then I want the function that called it to further check for more conditions. The issue I'm running into is that the custom input() returns, and the other function keeps running. Of course, I can have input() return some trashy value like -6573.34, and then have my function check for that value, and return if it detects it. However, I feel like there should be a more elegant way. Is there a "Return all" function I'm missing?

답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 23일
No, this has been discussed in the past, and the result has been that there is no way to do this short of quitting MATLAB itself.
You should consider throwing an error() . If there happens to be a level that has a try/catch block that eats the error, then it either handles the error smoothly (in which case perhaps it was not appropriate for you to want to return all the way up) or the layer should be edited to rethrow that error if it is "eating" it instead of dealing with it appropriately.
  댓글 수: 1
Matt Fig
Matt Fig 2011년 5월 23일
That is what I seemed to remember on further reflection.

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

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by