Info

此问题已关闭。 请重新打开它进行编辑或回答。

Using a "to file" block to log data every few time steps

2 次查看(过去 30 天)
Hello,
I am trying to log results from a Simulink system using to File blocks, but have run into issues. Right now the .mat files remain empty until the simulation has been stopped. How can I make a To File block start logging data during the simulation? From the documentation it seems like this should be possible.
Thank you.

回答(1 个)

Tushar Sinha
Tushar Sinha 2015-11-3
Hi Adam,
The default behavior of the "To File" block is to write to the output file incrementally, with minimal memory overhead during simulation. If the output file exists when the simulation starts, the block overwrites the file. The file automatically closes when simulation is complete or paused. If simulation terminates abnormally, the To File block saves the data it has logged up until the point of the abnormal termination.
Refer to the link below for more information on the same:
However, in your case, if you still see that the data is not getting logged during the simulation you can change certain properties to control when Data is written to the file. Refer to the steps below to achieve the same:
1) The To File block Decimation and Sample Time parameters control when data is written to the file.
2) The To File block does not log data outside of the intervals specified by the Model Configuration Parameters > Data Import/Export > Logging intervals parameter. The block stores the logged data in the file associated with the block instead of storing the data in the variable that you specify for the Save simulation output as single object parameter.
I hope the above information helps answer your question.
Thanks,
Tushar
  1 个评论
Adam Rhoads
Adam Rhoads 2015-11-3
编辑:Adam Rhoads 2015-11-3
Tushar,
Thank you for the information. Could you please explain this portion? "
"The To File block does not log data outside of the intervals specified by the Model Configuration Parameters > Data Import/Export > Logging intervals parameter. The block stores the logged data in the file associated with the block instead of storing the data in the variable that you specify for the Save simulation output as single object parameter."
I have modified the logging intervals parameter without any luck.

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by