Function 'daysact' not supported for code generation.
조회 수: 2 (최근 30일)
이전 댓글 표시
I am using this simple code inside a user defined Matlab function in SIMULINK
NumDays = daysact('20-March','21-March');
But it shows error that "Function 'daysact' not supported for code generation."
댓글 수: 0
채택된 답변
Walter Roberson
2021년 1월 14일
Correct. That function cannot be compiled.
The work-around is to use datetime and subtract.
dt1 = datetime('7-sep-2002','Locale','en_US')
dt2 = datetime('25-dec-2002','Locale','en_US')
NumDays = daysact(dt1, dt2) %what you cannot generate code for
NumDays2 = days(dt2-dt1) %replacement function
댓글 수: 0
추가 답변 (1개)
Sean de Wolski
2021년 1월 14일
You should use the newer and recommended datetime / duration classes which support c-codegen:
d = days(datetime(t1)-datetime(t2));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!