Hi Eghbal,
Offline, you asked: Is it possible for a MATLAB window script to be notified when an experiment is closed?
Unfortunately, it appears that this is not possible at present. When the experiment is closed, the MATLAB window resets itself, throwing away any accumulated events. This means that none of the events associated with the experiment closure are delivered to your MATLAB script, irrespective of the state of the synchronization variable at close time.
That said, I’m sure we can modify the MATLAB window to make this work. Let me think about the best way to do it.
Cheers,
Chris
Hi Eghbal,
I’ve implemented a solution to the problem of handling experiment closure from a MATLAB window script.
The MATLAB window now supports “cleanup” functions. If a file named foo_cleanup.m
exists in the same directory as foo.m
, and the MATLAB window executes function foo
at least once, then function foo_cleanup
will be executed when the MATLAB window resets (i.e. when the current experiment is unloaded). It will be called with the last value returned by foo
as its only argument. (In your case, I assume this will be a structure or array that contains open file handles that you want to close.)
I’ve attached a copy of the MATLAB window demo that includes a cleanup function.
This feature is in the current nightly build. When you have a chance, please try it out and let me know if it meets your needs.
Cheers,
Chris
Attachment: matlab_window_demo.zip (2.68 KB)