Write output of To File block to MAT file incrementally during simulation of generated executable
조회 수: 1 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2018년 10월 31일
답변: MathWorks Support Team
2019년 4월 25일
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
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!