Simulink Variable Time Logging
6 views (last 30 days)
Show older comments
Hi,
is it possible to get a simulink "to workspace" block to log the data with variable time steps? I have a model in which some parameters are used to send it to hardware and the testrig is basically controlled with my model. For some commands I send to the testrig it is not really useful to have the logged within the sample time I have for my model, for example some preparation steps when I change the temperature, which could take quite long. I tried to have the different sample times in a varaible in the base workspace and after the command in simulink/ stateflow is processed the variable is changed. I had the variable of the sample time in my "to workspace" block, and it seemed to work sometimes to refresh the block and it changed to a new sample time, but it kept it that way for the whole simulation. Do you have any suggestions on how I could do this or maybe a better way to do this?
0 Comments
Answers (1)
Paul
on 11 Sep 2024
One approach ...
Put a To Workspace block with inherited sample time inside a Triggered Subsystem.
Send the data to be logged as the input to the Triggered Subsystem and connect the subsystem Inport to the To Workspace block.
Trigger the subsystem at the times at which the data is to be logged.
3 Comments
Paul
on 11 Sep 2024
The approach I proposed would only record data when the subsystem is triggered, which you can do at arbitrary times based on whatever logic is applicable to your problem.
Or, instead of a triggered subsystem, maybe an an Enabled Subsystem with a To Workspace block inside will be a solution if you want to collect data for certain stretches of the simulation but not others.
I confess I don't 100% understand how you're determining when data should be logged or not, just providing some options for how data can be logged non-periodically.
See Also
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!