From: Francesco Aiello on
Hello, I recently started using matlab engine with c/c++ routines... to get started I tried to run the default sample files, as engdemo.c in the matlab root... and the amazing thing is that program seem to work, it produces the right outputs, takes the right input, but doesn't show anything in the workspace. It should be related to the engPutVariable function, but I can't understand why I can't see any variable in the workspace (as the time vector 'T')... I'm using a 2010a 32bit Matlab version, with the default LCC compiler (but I get the same result even with microsoft ones)... please can anyone help me?
From: James Tursa on
"Francesco Aiello" <aiellofrancesco(a)yahoo.fr> wrote in message <i1522k$pjp$1(a)fred.mathworks.com>...
> Hello, I recently started using matlab engine with c/c++ routines... to get started I tried to run the default sample files, as engdemo.c in the matlab root... and the amazing thing is that program seem to work, it produces the right outputs, takes the right input, but doesn't show anything in the workspace. It should be related to the engPutVariable function, but I can't understand why I can't see any variable in the workspace (as the time vector 'T')... I'm using a 2010a 32bit Matlab version, with the default LCC compiler (but I get the same result even with microsoft ones)... please can anyone help me?

Can't see the variable in *which* workspace? It won't appear in your usual MATLAB workspace because it isn't using *that* one. The engdemo program opens up a separate MATLAB session and uses that for the calculations & plotting, and then closes it. By the time the program quits the MATLAB engine (and 'T') is gone. If you want to keep it open and examine the variables in the engine workspace comment out these lines from engdemo.c:

engEvalString(ep, "close;");

engClose(ep);

That will leave the MATLAB engine running after the program quits and you and examine T and D etc. manually, and then close the engine yourself.

James Tursa
From: Francesco Aiello on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i15536$g32$1(a)fred.mathworks.com>...
> "Francesco Aiello" <aiellofrancesco(a)yahoo.fr> wrote in message <i1522k$pjp$1(a)fred.mathworks.com>...
> > Hello, I recently started using matlab engine with c/c++ routines... to get started I tried to run the default sample files, as engdemo.c in the matlab root... and the amazing thing is that program seem to work, it produces the right outputs, takes the right input, but doesn't show anything in the workspace. It should be related to the engPutVariable function, but I can't understand why I can't see any variable in the workspace (as the time vector 'T')... I'm using a 2010a 32bit Matlab version, with the default LCC compiler (but I get the same result even with microsoft ones)... please can anyone help me?
>
> Can't see the variable in *which* workspace? It won't appear in your usual MATLAB workspace because it isn't using *that* one. The engdemo program opens up a separate MATLAB session and uses that for the calculations & plotting, and then closes it. By the time the program quits the MATLAB engine (and 'T') is gone. If you want to keep it open and examine the variables in the engine workspace comment out these lines from engdemo.c:
>
> engEvalString(ep, "close;");
>
> engClose(ep);
>
> That will leave the MATLAB engine running after the program quits and you and examine T and D etc. manually, and then close the engine yourself.
>
> James Tursa


Thank you, that helped a lot, I can actually find the variables in that workspace. Despite this, have I been mistaken while watching the official webinary? I thought variables were sent to the main workspace (that's what "seems" to be shown in it, variables appear directly in the main workspace: http://www.youtube.com/watch?v=0DUxzXuIKRM). Thank you again for your precious help.
From: James Tursa on
"Francesco Aiello" <aiellofrancesco(a)yahoo.fr> wrote in message <i1595j$ejg$1(a)fred.mathworks.com>...
>
> Thank you, that helped a lot, I can actually find the variables in that workspace. Despite this, have I been mistaken while watching the official webinary? I thought variables were sent to the main workspace (that's what "seems" to be shown in it, variables appear directly in the main workspace: http://www.youtube.com/watch?v=0DUxzXuIKRM). Thank you again for your precious help.

I am not familiar with that video series. But basically, whenever you open up a MATLAB engine you need to think of it as a brand new MATLAB session that is not connected in any way to any currently running MATLAB session. There are ways of *getting* things connected up, but that is not the default. So be careful. The MATLAB engine will start up in the regular MATLAB start-up directory, which will *not* necessarily match up with the current directory of any currently running MATLAB session.

James Tursa