I’m writing a code in matlab, in this code I have a function f() that calls the function g() that calls the function h().
Function f() calls g() in a for loop that iterates 101 times, and g() calls h().
Each iteration, h() displays an image, the user does some changes to the image until he presses the Enter or the O keys:
- If he presses Enter
h()returns a file of the changes he made, and continues to the next image. - If he presses O then
h()returns the file of the changes. but doesn’t continue to the next images, instead, it returns toMain.
Its like exit(1) in C.
Any ideas how can I do it?
I think you’re looking for
return. Though it won’t return you immediately to h, you’ll have to putreturnin g somewhere as well.As long as you name at least one output variable in the function declaration, the output will be returned no matter whether you use
returnor not.For example: