How can I use Matlab command line to [open/close/export as *.fig] signal viewer interfaces in Simulink (2021b?)

3 ビュー (過去 30 日間)
Cory Dinkle
Cory Dinkle 2021 年 12 月 20 日
回答済み: Nithin 2023 年 10 月 13 日
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.

回答 (1 件)

Nithin
Nithin 2023 年 10 月 13 日
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.

カテゴリ

Help Center および File ExchangeScopes and Data Logging についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by