FAQ 510: RTT : How to set up Infinite replay of MAT/MF4 Files
Question
How to set up infinitely replay of mat and mf4 files with Real-Time Testing (RTT)?
Solution
In Signal Editor, you can set a finite value from a property. However, you cannot set infinite.
On the other hand, RTT can replay infinitely.
The code below is a sample code that assigns the parameter values Signal1 defined in the MAT file to Constant1 of Model Root, respectively, and flows data at the cycle defined in Time.
Sample Code:
from rttllib import variable
from rttllib import datastream
# Create Variable objects
Const1 = variable.Variable(r'Platform()://Model Root/Constant1/Value')
# Create VariableToStimulate
VariableToStimulate = datastream.CreateVariableMap("Time")
VariableToStimulate.AddVariable("Signal_1", Const1)
# Create MyStream
MyStream = datastream.MatFile(r'(MAT file path)', VariableToStimulate)
# Define MainGenerator
def MainGenerator():
# Start Replay
yield MyStream.Replay()
The process of MAT/MF4 file replay in RTT is shown above.
Up to line 14 is for settings such as which model variables to assign signals in the MAT file, and the actual playback instructions are in the last line.
If you want to make an infinite loop in RTT, just change line 18 and after as follows.
while(True):
yield MyStream.Replay()
A demo file of an RTT similar to this one can be found here.
C:\Users\user \Documents\dSPACE\Real-Time Testing\<dSPACE Release>\10_DataStreaming\RTTSequences\RTTSequence.py
Limitation
- An RTT license is needed to do this.
- It is not possible to replay a mat or mf4 file infinitely in the Signal Editor.
Tags
| Date | 2026-10-30 |
| Information Type | Frequently Asked Questions |