Write output of To File block to MAT file incrementally during simulation of generated executable

조회 수: 1 (최근 30일)
I am generating an executable from my Simulink model in order to speed up execution. I output the data using a To File block. However, when I run the generated executable, I cannot access the data from the To File block until the very end of simulation. This is undesirable, since I am running a very long simulation and would like to see the intermediate results. Additionally, if the simulation is terminated early, all the data is lost. Is there a way to access the results while the executable is running? This is possible during Normal mode simulation by pausing the simulation.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2019년 4월 26일
When running a generated executable, the data written by the "To File" block cannot be accessed until the end of simulation because the file is open for writing. A simple workaround is to create a custom S-function that writes the desired outputs to a text file during simulation. To do so, you can use the "S-function Builder" block. I have attached a simple model containing an S-function that buffers data and writes to a file every "x" time steps, where "x" is specified as a parameter of the S-function. This is only a simple example, and you can modify it as fit for your model.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by