MATLAB Answers

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

2 views (last 30 days)
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
function My_Func(a)
% matlab_local_variable = Several calculations
% at this point I want to compare 'matlab_local_variable' with 'c_local_variable'
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:
% 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?


Sign in to comment.

Answers (0)