Detecting experiment closure from MATLAB window script
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
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Christopher Stawarz closed this discussion on 11 Jul, 2016 06:01 PM.
Support Staff 1 Posted by Christopher Sta... on 11 Oct, 2016 02:24 PM
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 asfoo.m
, and the MATLAB window executes functionfoo
at least once, then functionfoo_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 byfoo
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
Christopher Stawarz closed this discussion on 30 Nov, 2016 03:46 PM.