Wrong number of arguments in the Matlab function
Afficher commentaires plus anciens
whenever I run the below code, it's executed successfully. I want to convert it into C code by Matlab coder app. But It's showing error.

soc=60;
y=libonoff(soc)
function [y]=libonoff(soc) %#codegen
if soc>=80
lib=0;
else
lib=1;
end
y=lib;
end
3 commentaires
Stephen23
le 13 Mar 2023
As the error message states, the function LIBONOFF requires one input argument, but you are calling it with zero input arguments. What do you expect to occur, when you call it with no input arguments?
Ismat
le 13 Mar 2023
Matan Silver
le 14 Mar 2023
Hi Ismat,
My last comment was incorrect so I've deleted it so as to not mislead anyone. Stephen above is correct. It looks like you typed "libonoff" when the GUI asked you to provide a command or script that exercises your entrypoint. However, the function expects an input. So you should either provide "libonoff(1)", or the name of your script that internally calls libonoff, in order to correctly exercise the entry-point. MATLAB Coder is behaving as expected in this case, since you are calling the function with no inputs when it expects one input.
Thanks and let me know if you have any questions,
Matan
Réponses (0)
Catégories
En savoir plus sur MATLAB Coder dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!