How to make a continous csv export in Simulink
조회 수: 29 (최근 30일)
이전 댓글 표시
Hi,
I have a Simulink model that runs for an infinite time in time steps of 1 second.
The Simulink model generates some setpoints for another application that needs to be published in a CSV file.
The idea is that Simulink writes and overwrites its calculated setpoints to a CSV file after each time step of 1 second.
I struggle to find a way to achieve this, can somebody help with this?
Regards,
Damien
댓글 수: 2
Mili Goyal
2023년 2월 20일
I think the following links can be helpful sources of information for your query:
답변 (1개)
Anshuman
2023년 2월 20일
Hi Damien,
To my understanding you are trying to export the result of simulation of a Simulink model to a CSV file after every time step. There is no direct way to export simulation results to a CSV file but there are some possible workarounds.
1. To File block - This block writes your signal data to a MAT file and keep overwriting it until the simulation stops.
You can refer to this link for more detail:
Later you can convert that MAT-file to a csv file:
FileData = load('FileName.mat');
csvwrite('FileName.csv', FileData.M);
2. You can also try logging your signal data (right-click the signal and select Signal Properties) and now when you run the model and then click on Data Inspector in Review Results tab in Simulation strip, there you can find an option to export your data in a MAT-file, which you can convert into a csv file by the above approach.
Hope this helps!
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!