How to save the last value of a simulation in a .mat ?
이전 댓글 표시
Hello,
I'm having some troubles with something that looks easy : I would like to save the last value of a Simulink simulation to be stored in a .mat file without passing by a .m script. Kind of like a mix between the to-File block and the "Limit data point to last" option of the scopes, to Workspace, etc...
I know that the To-File block is able to log all the simulation but i really only need the last step !
Thank you in advance !
Aurelien
답변 (1개)
Sebastian Castro
2015년 3월 8일
0 개 추천
Hello Aurelien,
Have you looked into saving a SimState? While the format might be different, it is a functionality we provide for saving data at the end of a simulation (presumably to use at the beginning of another simulation).
- Sebastian
댓글 수: 2
Aurelien Fremeaux
2015년 3월 9일
편집: Aurelien Fremeaux
2015년 3월 9일
Sebastian Castro
2015년 3월 9일
If you want this to work after auto code generation, I guess you could use the Configuration Parameters as shown below:
1. In the Data Import/Export pane, you can enable whatever type of logging that will get you your data. Also, check "Limit data points to last" and change the value to 1 such that you only get the last data point out.
2. In the Code Generation > Interface pane, check the "Enable MAT-File Logging" box. This should be available for both "grt.tlc" (Simulink Coder) and "ert.tlc" (Embedded Coder).
Note that the MAT-file logging works with the following blocks (from the documentation).
Enable MAT-file logging . When you select this option, the generated code saves to MAT-files simulation data specified in one of the following ways:
- Configuration Parameters > Data Import/Export, Save to workspace subpane (see Data Import/Export Pane)
- To Workspace blocks
- To File blocks
- Scope blocks with the Save data to workspace parameter enabled
- Sebastian
카테고리
도움말 센터 및 File Exchange에서 Save Run-Time Data from Simulation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!