Question
Without using datevec, how can I get machine / computer real date and time into a simulink model for dSpace Real Time simulation?
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 16, 2026
When working with Simulink in a dSPACE Real-Time Model, you can obtain the machine’s date and time for real-time simulations. Here are two approaches:
-
Using Embedded MATLAB Function Block:
- Add an Embedded MATLAB Function block to your Simulink model.
- Inside the block, use the following code snippet to retrieve the date and time components:
function [Y, M, D, H, MN, S] = getDateTime() eml.extrinsic('now'); eml.extrinsic('datevec'); nowTime = now(); [Y, M, D, H, MN, S] = datevec(nowTime); end - The output variables
Y,M,D,H,MN, andSrepresent the year, month, day, hour, minute, and second, respectively1.
-
Using Real-Time Interface (RTI) with dSPACE Hardware:
- If you’re using dSPACE hardware, the Real-Time Interface (RTI) allows seamless integration of Simulink models with dSPACE systems.
- RTI provides blocks that implement I/O capabilities for dSPACE hardware within your Simulink models.
- While this doesn’t directly provide the machine date and time, it’s essential for real-time simulations and hardware-in-the-loop testing2
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related MATLAB Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →