Function 'daysact' not supported for code generation.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Muhammad Usman
el 14 de En. de 2021
Respondida: Walter Roberson
el 14 de En. de 2021
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 comentarios
Respuesta aceptada
Walter Roberson
el 14 de En. de 2021
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 comentarios
Más respuestas (1)
Sean de Wolski
el 14 de En. de 2021
You should use the newer and recommended datetime / duration classes which support c-codegen:
d = days(datetime(t1)-datetime(t2));
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!