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(...);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by