MatlabWindow changes: add a log window

This is a new version of the matlab window that displays the output from Matlab in a text frame. I have found this essential for debugging matlab code.

I apologize for the state of the code, it’s not super-elegant.
Also there is one known bug - if the experiment is running when you click “Reset”, the client will crash. I assume this is a deadlock issue but I have not tracked it down.

Screenshot, patch, and zip file of our current code are attached. (patch probably does not have changes to nib/xcode xml files).

Mark

Attachments:

Hi Mark,

I’ve finally started to work on merging in your patches. Sorry for taking so long to get to it!

The MATLAB window stuff looks pretty good. There are a few bits I’m going to change, but overall it looks solid.

One problem: The zip file you sent didn’t include printErrorStack.m, which looks to be important. Can you send me a copy of that?

Also, I’m curious why printErrorStack (and the try/catch block it’s part of) is necessary. Does MATLAB not send error output to the buffer set by engOutputBuffer?

Thanks,
Chris

Hi Chris,
thanks!

I’m attaching printErrorStack.m plus a few other files we use here that might be useful in an MW matlab toolbox

Also, I’m curious why printErrorStack (and the try/catch block it’s part of) is necessary. Does MATLAB not send error output to the buffer set by engOutputBuffer?

No, it does not. In a recent release they started sending error output to stderr which apparently engOutputBuffer does not catch (This may depend on matlab version - I have used 2008a,b and 2009a but haven’t determined which versions are problematic). Figuring out how to do that with try/catch made my debugging life an order of magnitude easier.

Mark

Attachments:

Hey Mark,

I just committed your patch to my git repo. I made a few changes, mostly to fix memory management issues. Also, prior to applying your patch, I had converted MATLABWindow’s NIB to a XIB, so I had to recreate the log window in Interface Builder. In addition, the scripts you sent me are now installed into “/Library/Application Support/MonkeyWorks/Scripting/Matlab”. You can check out the latest code at

The updated MATLABWindow will be included in the nightly build starting tonight. I’d appreciate it if you’d download the nightly and test out the log window, to make sure it works as intended. For instructions on obtaining and installing the nightly build, see

https://mworks.tenderapp.com/faqs/installation/install-mworks

Thanks,
Chris

Hi Chris,

Thanks! Clearly I am not an expert on Cocoa memory management or the IB/handle stuff.

I’d like Jon Hendry to do most of the testing here, and this seems like a good way to get him going with it. So I’m going to ask him to pull the nightly and test it on our testing setup here. This may take a few weeks, if that’s ok.

best,
M

Hi Mark,

I’d like Jon Hendry to do most of the testing here, and this seems like a good way to get him going with it. So I’m going to ask him to pull the nightly and test it on our testing setup here. This may take a few weeks, if that’s ok.

That sounds fine. There’s no rush – I’d just like someone in your lab to try the MATLAB window out and verify that it still works as intended. It’ll be in the nightlies from now on, so Jon can test it at his leisure.

Thanks,
Chris