Borrar filtros
Borrar filtros

How to use .m file when using Autodefine Input Types and mex file when running

2 visualizaciones (últimos 30 días)
Is there a way in for my matlab code to understand that my script is being run via the "Autodefine Input Types" in the MATLAB Coder project gui? There is coder.target, but
coder.target('MATLAB')
returns true which also returns true when just running the script from the matlab command window.
What I want to have happen is:
if (running_normally)
mex_file('my_function', args);
elseif (generating_mex_file || running_Autodefine_Input_Types)
my_function(args);
end

Respuestas (1)

Pratyush
Pratyush el 15 de Feb. de 2024
Hi Nathan,
To differentiate between normal execution and various stages of code generation in MATLAB, including the "Autodefine Input Types" phase in MATLAB Coder GUI, you can use conditional checks with "coder.target". While there's no direct way to detect the "Autodefine Input Types" phase, you can use the following logic:
  • Use "coder.target('MEX')" to determine if the code is being generated for a MEX file.
  • Use "coder.target('codegen')" to check for any code generation process, which would cover the "Autodefine Input Types" phase.
  • Use an "else" statement for normal execution when not generating code.
This allows you to run different code paths depending on whether you are generating MEX files, running the "Autodefine Input Types" phase, or executing your script normally.

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by