探索全新的 mydSPACE 服务: 许可证管理、全新的 dSPACE 帮助以及用于用户文档的 dSPACE 聊天机器人。请访问我们的专用支持页面,获取更多信息和支持。 链接了解更多并获取支持

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
资料信息 常见问答

通过 dSPACE时事通讯服务了解最新信息。

通过 dSPACE 时事通讯服务,我们将随时向您通报当前的使用案例、新解决方案和产品以及培训和活动。在此注册,免费订阅。

Enable form call

At this point, an input form from Click Dimensions is integrated. This enables us to process your newsletter subscription. The form is currently hidden due to your privacy settings for our website.

External input form

By activating the input form, you consent to personal data being transmitted to Click Dimensions within the EU, in the USA, Canada or Australia. More on this in our privacy policy.