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

1 回表示 (過去 30 日間)
zohar
zohar 2019 年 1 月 10 日
編集済み: zohar 2019 年 1 月 10 日
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 件)

カテゴリ

Help Center および File ExchangeCall MATLAB from C についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by