How could I attach start time stamp to save data file in simulink?

4 views (last 30 days)
Hello,
I have a Simulink model that collects some data from and external source. Multiple block outputs are connected to a Bus which are then connected to e 'To File' block to save the data to file.
I need to know the start time of the acquisition (when the model starts running), and I would like to attach the time stamp automatically to the end of the file being saved (i.e. 'filename_yyyy-mm-dd_HHMMSS.mat').
I have manipulated the 'startFcn' callback of the model to create a time stamp and save it in workspace. I tried to manipulate the 'stopFcn' callback to the 'To File' block to add the time stamp to the end of the name, or alternatively I try to use the 'movefile' function to move the file to another with the full name (with time stamp).
The problem is that (with both approaches) I get an error/warning message saying that 'No Matching Files Were Found' or that 'You can not rename a file while the model is running'; both of which I believe is due to the fact that at the point when the 'stopFcn' callback is being executed the model hasn't fully stopped yet.
Any ideas on how I could get around this problem or another way I could use to do what I want; are much appreciated.
Thank you.

Answers (0)

Categories

Find more on Modeling in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!