How to get system date and time into simulink?
81 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jan De Vries
el 28 de Feb. de 2012
Comentada: Srikar
el 11 de Dic. de 2023
Is there a way to get the system date and time (not simulation time) into simulink?
2 comentarios
Respuesta aceptada
TAB
el 28 de Feb. de 2012
Use below code in embedded matlab function block. It will give the date and time components as separate output.
function [Y, M, D, H, MN, S] = fcn()
eml.extrinsic('now');
eml.extrinsic('datevec');
Y = 0;
M = 0;
D = 0;
H = 0;
MN = 0;
S = 0;
[Y, M, D, H, MN, S] = datevec(now);
end
4 comentarios
Kaustubha Govind
el 24 de Jun. de 2013
Sathish: Please post this as a new question along with your code.
Más respuestas (4)
Rick Rosson
el 28 de Feb. de 2012
A slightly simpler version:
function [Y, M, D, H, MN, S] = sysClock()
coder.extrinsic('clock');
Y = 0;
M = 0;
D = 0;
H = 0;
MN = 0;
S = 0;
[Y, M, D, H, MN, S] = clock;
end
1 comentario
Rick Rosson
el 28 de Feb. de 2012
5 comentarios
Walter Roberson
el 7 de Mzo. de 2016
There is no way to fetch only the time without the date. The sysClock routine that Rick showed above can be modified to discard the date portions and return only the time components.
Kareem Abdelgawad
el 24 de Nov. de 2014
I tried to use it under 'Real-Time Windows Target', but it doesn't work. Any ideas how to read system time under 'Real-Time Windows Target'?
2 comentarios
shu
el 22 de En. de 2015
Me too. With the error of "The extrinsic function 'clock' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated."
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!