MATLAB Answers

Send variable from c to matlab

19 views (last 30 days)
zohar
zohar on 30 Oct 2011
Commented: Walter Roberson on 13 Jun 2018
Hi all,
I have a c program that set variable into matlab, using matlab Engine.
ep = engOpen(NULL);
...
engPutVariable(ep, "var", var);
Everything is OK except that I want to send the variable,
to regular matlab workspace
and not to matlab Engine.
Any help ???
thx

  1 Comment

Marisol Sierra
Marisol Sierra on 13 Jun 2018
Hey did you solve this problem?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 30 Oct 2011
Your C program is the "MATLAB engine" in MATLAB terminology.
I have not been able to establish this as a fact so far, but as best I can tell reading between the lines, engPutVariable() writes the variable into the "base workspace" of the MATLAB process associated with the engine.
There is no mechanism provided to write a variable in to the workspace of a particular function because no functions can be running in the MATLAB process at the time engPutVariable() is executed (or so my reading suggests.)

  6 Comments

Show 3 older comments
Walter Roberson
Walter Roberson on 3 Nov 2011
The MATLAB Engine interface is the wrong interface for such things. The Engine interface is primarily for doing computations.
The MATLAB Automation Server might be more appropriate. See
http://www.mathworks.com/help/techdoc/matlab_external/f135590.html
Marisol Sierra
Marisol Sierra on 13 Jun 2018
Hey... did you solve the problem?
Walter Roberson
Walter Roberson on 13 Jun 2018
Correction to a minor point from my 2011 posting:
i and j are not variables that exist by default. Instead, i and j are functions, just like pi and inf and nan

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags