MATLAB Answers

Using engine, How to set variable inside to MATLAB function?

6 views (last 30 days)
zohar
zohar on 10 Jan 2019
Edited: zohar on 10 Jan 2019
Hi all,
I am building c++ algorithm based on matlab algorithm, and I want to compare the results.
I am using matlab engine to set and get variables from matlab workspace.
When I am debugging inside function of matlab I can't set any variables to function workspace,
for example:
% main function
a = 5;
% ...
% ...
% Call to My_Func
My_Func(a)
%...
%...
function My_Func(a)
% matlab_local_variable = Several calculations
% at this point I want to compare 'matlab_local_variable' with 'c_local_variable'
end
When the debugger is in the main function I can get variable a , and also to add another variables using engGetVariable\engPutVariable.
When the debugger is inside My_Func:
get: In order to get any local variable I copy it to base workspace using:
assignin('base','matlab_local_variable',matlab_local_variable)
% now I can use engGetVariable(pEngine,'matlab_local_variable') from c++
set: When I using engPutVariable(pEngine,"c_local_variable", c_local_variable);
'c_local_variable' apears only in the base workspace and not inside My_Func
How can I compare matlab_local_variable with c_local_variable when the debugger is inside My_Func?
thx

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.

Tags