How to Define Function Input Parameters with Assert for Code Generation?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!