フィルターのクリア

Using Matlab Coder on script which calls several functions

2 ビュー (過去 30 日間)
Francesco
Francesco 2014 年 11 月 7 日
コメント済み: Francesco 2014 年 11 月 12 日
Hello,
I have a question using Matlab Coder.
I have a .m file I would like to convert. Schematically it's like such:
[a,b,c] = function1(e,f,g);
.
.
calculations
.
.
call to matlab function2;
call to matlab function3;
.
.
calculations
.
.
end
I would like to know how to, or whether it's possible, to just convert the actual script function1, and not the functions it calls, merely to pass the information calculated in the script to the other matlab functions2 and 3, without converting them (mainly because it would be a real headache).
Cheers,
Francesco

採用された回答

Ryan Livingston
Ryan Livingston 2014 年 11 月 9 日
Are you generating a MEX function? If not, i.e. you are generating standalone code, then you'll need to provide some replacements for function2, function3.
Assuming you are generating a MEX function, one suggestion could be to refactor function1 so that the "calculations" are in separate functions. Generate MEX functions for those new calculation functions and call the generated MEX from function1:
function [a,b,c] = function1(d,e,f)
[x,y,z] = calculation1_mex(d,e,f);
call to function1
call to function2
calculation2_mex(d,e,f);
Alternatively, you could consider declaring function2 and function3 as extrinsic functions:
function [a,b,c] = function1(d,e,f)
coder.extrinsic('function1','function2');
calculations
call to function1
call to function2
calculations
You can see the doc link above for a description of how to access the outputs, if any, from these functions. The general idea is to assign the output before the call:
% Update the size, complexity and
% data type to match what function1
% returns
y = zeros(10,12);
y = function1(...);
  1 件のコメント
Francesco
Francesco 2014 年 11 月 12 日
Hi,
coder.extrinsic() did the trick :)
Francesco

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by