Datetime arithmetic in simulink
이전 댓글 표시
Hello, is it possible to do datetime arithmetic in simulink? Eventually, the code may be autogenerated to C++.
for example, in matlab i would do:
dt0 = datetime([year month day hour min sec])
increment = 0.5 % seconds
dt1 = dt + seconds(increment);
답변 (1개)
You can do some arithmetics with datetime data type. For your example it is possible to add a duration to a datetime.
dt0 = datetime([2023 8 25 11 47 3]) % a point in time
increment = duration(0,0,5) % a duration of 5 seconds
dt1 = dt0 + increment % a 5 seconds later point in time
댓글 수: 4
Michael
2023년 8월 25일
In general a Simulink block is generating a signal (in case of of a source block) or manipulating a signal using block parameters or other signals. datetime or duration are no valid data types for signals. Or what is your intention to deal with those data types in Simulink?
MP
2023년 8월 25일
Michael
2023년 8월 25일
I am not familar with the Aerospace Blockset but according to documentation the Julian date conversion block supports only data type double on its inputs and its outputs. I don't see the nessity or possibility to deal with data type datetime or duration. But maybe it is possible to write a function within a MATLAB Function block with double inputs and double outputs where you convert those doubles into datetime and/or duration and convert the results back to doubles. But I am not sure if that is what you want
카테고리
도움말 센터 및 File Exchange에서 Unit Conversions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!