Matlab interface problem

Hi ,

I work with Ralf Brockhausen at the DPZ in Goettingen, and just got your recent email to him describing how to use the Matlab link to MWorks. I followed the instructions, and when I hit Prime Engine, Matlab starts up, but hitting Run Experiment does not produce any plots with the demo .xml and .m files loaded. I do get the values of rand_var printed out in the console window… but nothing in the matlab output window.

For example, in the console window:

00:01:26: Starting state system…
00:01:26: Display updates started (main = 69671680, current = 69671680)
00:01:26: Display updates started (main = 69671680, current = 69671680)
00:01:26: sync = 1 (86579001)
00:01:26: rand_var = 6 (86579082)
00:01:26: rand_var = 3 (86579140)
00:01:26: rand_var = 6 (86579196)
00:01:26: rand_var = 8 (86579253)
00:01:26: rand_var = 4 (86579310)
00:01:26: rand_var = 10 (86579368)
00:01:26: rand_var = 7 (86579425)
00:01:26: rand_var = 10 (86579482)
00:01:26: rand_var = 8 (86579539)
00:01:26: rand_var = 10 (86579596)
00:01:26: sync = 0 (86579663)
00:01:26: Display updates stopped
00:01:26: State system ending
00:01:26: Reseting experiment

Also, I read and understood the matlab_window_demo.m file. However, I am unsure of how the interfacing between MWorks and Matlab is happening. Is it via the Matlab engine ? Could you perhaps also indicate where in the source code this interfacing is happening, in case there is a clearly separate file or section to look at ?

Thanks, Suresh

Hi Suresh,

I work with Ralf Brockhausen at the DPZ in Goettingen, and just got your recent email to him describing how to use the Matlab link to MWorks. I followed the instructions, and when I hit Prime Engine, Matlab starts up, but hitting Run Experiment does not produce any plots with the demo .xml and .m files loaded. I do get the values of rand_var printed out in the console window… but nothing in the matlab output window.

Are you using MWorks 0.4.4 (the latest official release) or a nightly build? If you’re using 0.4.4, then you need to run the MATLAB window bugfix installer in order for the MATLAB window to function.

If you’re using a nightly build, or you experience the same problem after running the bugfix installer, then I’d suggest making sure that the “Synchronization Variable” field is set to “sync”. (Be sure to hit Return after typing “sync”; otherwise, the setting won’t take.)

Also, I read and understood the matlab_window_demo.m file. However, I am unsure of how the interfacing between MWorks and Matlab is happening. Is it via the Matlab engine ?

Yes, we interface with MATLAB via the MATLAB engine.

Could you perhaps also indicate where in the source code this interfacing is happening, in case there is a clearly separate file or section to look at ?

Sure, you can check out the source on GitHub. The main files to look at are MATLABInterface.m and MWMATLABWindowController.m.

Chris

Hi Chris,

Thanks for the note. I wonder how you included parts of my message into your reply, I cannot seem to find a way to do it :slight_smile:

I am using MWorks 0.4-5dev. After hitting “Enter”, I indeed got the histogram plotted, thanks !

I notice that you use the values variable back and forth between Matlab and MWorks. Is this better than just keeping the values in the Matlab session and then merging the new data in the next function call with the existing values , assuming this can be done easily perhaps via the “Automation” feature that I just read about ? I am trying to understand the niceties of the Matlab engine approach here.

Also, I assume that MWorks is saving the data independent of the Matlab interface ? So the Matlab program does not have to take care of any data saving ?

Very best, Suresh

I wonder how you included parts of my message into your reply, I cannot seem to find a way to do it :)

In Tender, you can format messages using Markdown. To quote text, use the blockquote syntax.

I notice that you use the values variable back and forth between Matlab and MWorks. Is this better than just keeping the values in the Matlab session and then merging the new data in the next function call with the existing values , assuming this can be done easily perhaps via the "Automation" feature that I just read about ?

If you have a way to keep the values in MATLAB, then that might be a good option. For example, you may be able to declare a global variable from within your MATLAB function and store accumulated values to that. However, I don't know MATLAB well enough to say whether that's possible.

Also, I assume that MWorks is saving the data independent of the Matlab interface ? So the Matlab program does not have to take care of any data saving ?

If you're streaming to a data file, then MWorks will record all events that occur during your experiment, including any you may be sending to MATLAB. For info on how to unpack an MWorks data file, see these discussions.

Chris