Using Matlab Coder on script which calls several functions
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Francesco
el 7 de Nov. de 2014
Comentada: Francesco
el 12 de Nov. de 2014
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
0 comentarios
Respuesta aceptada
Ryan Livingston
el 9 de Nov. de 2014
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);
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(...);
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Coder en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!