How to get an ouput of a function in a try block ?

1 次查看(过去 30 天)
Hello !
I have the following function:
try
h = MyFunction(arg1,arg2);
catch
close(h);
end
Unfortunately it doesn't run because if an error occurs in MyFunction, ouput h isn't in the workspace of the main function. Yet, h is set in MyFunction before the error occurs.
How can I close a window opened by MyFunction, with the handle h, if an error occurs in MyFunction ?
Thank you for your help.

采纳的回答

Sean de Wolski
Sean de Wolski 2011-11-30
Add a try block to MyFunction!
Well that's the easiest way and it's pretty safe. You could also use assignin if you really just want h.

更多回答(2 个)

David Young
David Young 2011-11-30
Open the window first, and pass it as an argument to MyFunction.

Christophe
Christophe 2011-11-30
Thank you for your answer !

类别

Help CenterFile Exchange 中查找有关 Event Functions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by