Loading .mat file before running MAtlab scripting

Concerning processing components: filters, file load/save, visualizations, communication ...
Post Reply
hkn1304
Posts: 13
Joined: Tue Apr 18, 2017 5:44 am

Loading .mat file before running MAtlab scripting

Post by hkn1304 »

Hello,

I would like to embed some variables created in Matlab into Openvibe so that i can process in Openvibe through Matlab scripting.

However, i had no success at all. When i implement "load('xxxx.mat')" into initialize function it gives me error and can't get even data from EEG headset. When i try to implement into process function this time another OV_BOX_xxxxxxx seemed however when i try to get in nothing shows up.

By the way, i came across everytime i run the xml, i came across different OV_BOX _xxx name.

Does someone know how to do or tried this?

Thanks.

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Loading .mat file before running MAtlab scripting

Post by jtlindgren »

Hi Hkn,

you can try to get matlab to stop (breakpoint) on errors and then inspect the contents of the various variables and see if they make sense and whats in them.

In particular, loading a file might fail if the file in question is not in the current directory of the matlab interpreter -- in that case, provide the full path to the file.

The OV_BOX_XXXX are unique (or random) identifiers given to boxes run time. Each keeps the information specific to one Matlab scripting box running code. This way, multiple matlab boxes can be run at the same time, each with their own information and state.

The .m files among the matlab box tutorials shipped with OpenViBE should show how to stream data into Designer, if thats what you want to do.


Cheers,
Jussi

hkn1304
Posts: 13
Joined: Tue Apr 18, 2017 5:44 am

Re: Loading .mat file before running MAtlab scripting

Post by hkn1304 »

Thanks Jussi, with your suggestion i add a line "addpath(genpath('C:\Program Files (x86)\openvibe\share\openvibe\scenarios\box-tutorials\matlab')); into matlab but it didn't change anything.

I would like to visualize what i have done:

Notwithstanding the original scenario, i think scenario shown in "Matlab scripting box inside"picture would be sufficient to visualize what i plan.

You can see the what is inside of the script described in Scripting box in "Scripts fed into Matlab scripting box" picture.
required mat file is in the same directory specified in Scripting box.

In conclusion, when i write "whos" in the Command window(popped) i cannot see variables in my .mat file.

Hope the problem is clear now.
Any suggestions?
Attachments
Command window popped while i hit run
Command window popped while i hit run
popped Command window.PNG (69.69 KiB) Viewed 5268 times
Scripts fed into Matlab scripting box
Scripts fed into Matlab scripting box
scripts.PNG (101.42 KiB) Viewed 5268 times
Matlab scripting box inside
Matlab scripting box inside
matlab scripting inside.PNG (148.28 KiB) Viewed 5268 times
Last edited by hkn1304 on Mon May 22, 2017 9:18 am, edited 1 time in total.

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Loading .mat file before running MAtlab scripting

Post by jtlindgren »

I'm not quite sure, I can't check right now, but providing the full path shouldn't do harm (unless you plan to move your experiment somewhere else).

Regarding breakpoints, this should help,

https://fr.mathworks.com/help/matlab/ref/dbstop.html

Maybe you can even write the dbstop directive to the .m launched if you're not able to type to the console.


Cheers,
Jussi

hkn1304
Posts: 13
Joined: Tue Apr 18, 2017 5:44 am

Re: Loading .mat file before running MAtlab scripting

Post by hkn1304 »

DEbug commands not available when using Matlab as engine, it says. I 'm stucked,phew.

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Loading .mat file before running MAtlab scripting

Post by jtlindgren »

Looking at your picture, one thing in general which you should not do is to use anything under Program Files\ as a working directory for OpenViBE, as typically programs have no write access there on Windows.

Regarding paths, I'm not sure addpath() changes paths that load() sees. Maybe -- I don't know! What I meant was rather you'd write something like

load('C:\someplace\blah.mat');


Cheers,
Jussi

Post Reply