Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
zohar
zohar le 10 Jan 2019
Modifié(e) : zohar le 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

Réponses (0)

Catégories

En savoir plus sur Debugging and Analysis dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by