How can I use Matlab command line to [open/close/export as *.fig] signal viewer interfaces in Simulink (2021b?)
4 views (last 30 days)
Show older comments
In my Simulink model, I have many Floating Scopes within various subsystems. From the Command Line in Matlab, I would like to:
- Open '/FloatingScope'
- Scale X & Y Axis Limits
- Print to Figure
- Save Figure as *.jpeg
- Save Figure as *.fig
- Close Figure
- Close '/FloatingScope'
Is this possible? I would love achieve this in this manner, otherwise I need to recreate my Floating Scopes entirely with logsout signals, which would be extremely tedious, as there are dozens of Floating Scopes within our model.
0 Comments
Answers (1)
Nithin
on 13 Oct 2023
Hi Cory,
I understand that you want to [open/close/export as *.fig] signal viewer interfaces in Simulink using Command Line in MATLAB.
To implement this, kindly refer to the following steps:
1. Open the Floating Scope:
open_system('/FloatingScope')
2. Scale the X and Y-axis limits:
% Define your desired limits
xLimit = [xMin, xMax];
yLimit = [yMin, yMax];
% Set X and Y axis limits
set_param('/FloatingScope/ScopeName', 'XMin', num2str(xLimit(1)));
set_param('/FloatingScope/ScopeName', 'XMax', num2str(xLimit(2)));
set_param('/FloatingScope/ScopeName', 'YMin', num2str(yLimit(1)));
set_param('/FloatingScope/ScopeName', 'YMax', num2str(yLimit(2));
3. Print to a figure:
print('/FloatingScope/ScopeName', '-sFigure', '-dpng', 'output.png');
4. Save as *.jpeg:
saveas(gcf, 'output.jpeg', 'jpeg');
5. Save as *.fig:
saveas(gcf, 'output.fig', 'fig');
6. Close the figure:
close gcf
7. Close the Floating Scope:
close_system('/FloatingScope')
I hope this answer helps you.
Regards,
Nithin Kumar.
0 Comments
See Also
Categories
Find more on Interactive Model Editing 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!