Wrong number of arguments in the Matlab function

조회 수: 4 (최근 30일)
Ismat
Ismat 2023년 3월 13일
댓글: Matan Silver 2023년 3월 14일
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)
y = 1
function [y]=libonoff(soc) %#codegen
if soc>=80
lib=0;
else
lib=1;
end
y=lib;
end
  댓글 수: 3
Ismat
Ismat 2023년 3월 13일
So far I know, it's not possible to generate C/C++ executable code from Matlab scripts rather than Matlab function. My function works properly in my script. In the process of code generating how to call it with an input aruguments in a function? generally we call it in the script.
Matan Silver
Matan Silver 2023년 3월 14일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by