How to automatically fit all Scopes at the end of a simulation (stops by "End" block instead of final time)
Aloha Activate aficionados ,
I am wondering if there is a method (e.g., a command I can execute in the Finalization script) that will auto fit all of the scopes in my model.
In the model I have, I end the simulation with an "End" block based on a condition detected (e.g, controller is able to meet the desired setpoint within an error tolerance), which typically means the simulation ends before the final time set in the Solver Settings dialog, and so the final time is used as the scope end and the scope may show a lot of empty space and compact the data I want to view. Instead of clicking each scope to auto fit, I wonder if I can do this with a command I can execute in the Finalization or something similar. Does anything exist for this purpose?
Thanks,
Andy
Answers
-
Thanks to my esteemed colleague, Fady Nassif, you can accomplish this with the attached example.
The key steps:
In Model Finalization, add the following commands which reference the desired scope to fit:
h=bdeGetScopeHandle(bdeGetCurrentModel,'Scaled Scope'); %<-- 'Scaled Scope' is the name of the scope. If it is in one or more Superblock, add their names to the path, e.g. 'Superblock1'/'Superblock2'/'Scaled Scope'
figure(h);
axis('tight');Hope this helps someone else!
Cheers,
Andy
0 -
As of release 2022.3, the time axis of scopes is automatically adjusted to the simulated time. If you stop the simulation before it reaches the end, the final time in the scopes is set to the stop time.
1 -
RoKet_21298 said:
As of release 2022.3, the time axis of scopes is automatically adjusted to the simulated time. If you stop the simulation before it reaches the end, the final time in the scopes is set to the stop time.
Cool beans, thanks Ronald for the heads up - I'll check it out when available.
Cheers -Andy
0