How to Define Function Input Parameters with Assert for Code Generation?

5 visualizaciones (últimos 30 días)
I am trying to use "assert" to define (precondition statement) parameters to a function for codegen to javascript via the use of the "Generate JavaScript Using MATLAB Coder" add-on. I could use the MATLAB internal tool to help convert to c/cpp, but I want the output to be JavaScript and this add-on sounds good!. Either way, I seem to be doing something wrong.
If I build with the assert line commented out, I get the error on the function declaration line 2: ??? Type of input argument 'myInteger' for function 'myTestFunction' not specified. Use -args or preconditioning statements to specify input types.
If I build with the assert line uncommented, I get the error on the assert line 3: ??? Assert will always fail. To delay detection until run time use coder.ignoreConst on the condition.
I am referencing the following pages on "assert" usage:
Thank you for the help!
-------------------------myfunction.m----------------------
%#codegen
function myTestFunction(myInteger)
%assert(isa(myInteger,'int32'));
tempInteger2 = myInteger;
end
------------------------start.m--------------------------------
function start()
integer1 = 1;
integer2 = integer1;
myTestFunction(integer2);
end

Respuestas (0)

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by