Hi, I have created a function to use in GUI. The problem is that the function sometimes doesn't response to specific inputs and it gives an error on command window. This is normal and there is no problem until here. On GUI, I want to create a dialog box for this situation like 'Wrong Input'. I know the code for the dialog box, but I could'nt figure out how to add it. I think it should be like if that function doesnt work, answer will be zero and if it works the answer will be one. If I can create something like that it will be possible to add that dialog box when the function doesn't work. How can I do that?
Simply, how can I see the response of the function? (like 1 or 0) Thanks
It depends on what "the function does not respond" exactly means. If it stops with an error message, use try catch to catch the error and the corresponding message. If a specific output is replied, simply obtain this output, when you call the function from the callback of the GUI. Afterwards you can display the results how ever you want.
If is exactly the same situation, when you call a built-in function like e.g. sin(). When the input is a string, an error is thrown. When invalid input values are provided, e.g. NaN, NaN is replied also, such that you can catch this by checking the output.
Finally I assume, the actual question is not clear yet.
Alright now it's clear!
Go to the error corresponding line, error line is probably given to you in the MATLAB error, or you may already know where is the error.
put it in a try catch
try code more code....
catch diagbox('corresponding error'); end
and you won't see any error on the command window, instead you will see a dialogbox with a message and ...
I'm not sure if diagbox is the correct speling, check the MATLAB help plz, also for further options about dialog box.