Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
zohar
zohar am 10 Jan. 2019
Bearbeitet: zohar am 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

Antworten (0)

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by