필터 지우기
필터 지우기

How to log simulink to file at every sample?

조회 수: 2 (최근 30일)
Piotr Kluczek
Piotr Kluczek 2022년 8월 24일
댓글: Nikhilesh 2022년 9월 14일
I am trying to make Simulink log the simulation logs into a file at every simulation step.
The tools I found (To File block, "Log Dataset data to file" in Configuration Parameters) let me save logs to the file. They do create specified files at the beginning of the simulation but data can be read only at the end. I checked that out by running the simulation and aborting Matlab via Task Manager.
Due to Simulink freezing at some point (probably some 3rd party tool issue, not this issue scope) I cannot get to the end and need to abort Matlab. Hence I receive unreadable file (it gains weight during simulation but seems empty when opened by Matlab), or the proper structure with 0 element timeseries.
  댓글 수: 1
Nikhilesh
Nikhilesh 2022년 9월 14일
In case of Simulink Real-Time applications when running in 'External' simulation mode, the best way to log the data is to use the 'Scope' block from the 'Simulink Real Time' libraries instead of Simulink libraries. Following documentation provides more information on this block
Now, modify the following option the 'Simulink Real Time Scope' block to achieve desired results
  • Select 'Scope type' drop down to 'File'
  • Enter the value in the 'Decimation' filed. How decimation works here is, let us take, the 'Fixed-step size (fundamental sample time)' in the 'Model Configurations -> Solver -> Addition parameters' section is 0.00025 and 'Stop time' is 10. If we log data with 'Decimation' as 1 then the logged file consists of 40001 points (10/0.00025 = 40000 + 1) and if the we log data with 'Decimation' as 10 then the logged file consists of 4001 points (10/0.00025/10 = 40000/10 + 1).
  • Enter 'Filename' field. Let us take, 'data1.dat' is the file name that consists of logged data
After providing the above information, use the following commands to bring that file to host machine
>> tg.start; % to check if the target is connected or not
>> SimulinkRealTime.copyFileToHost('data1.dat')
>> SimulinkRealTime.utils.getFileScopeData('data1.dat')

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Logging에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by