Simulink scope autoscale
Ältere Kommentare anzeigen
Hi everyone, i was wondering if there is a way for a scope i use in a simulink model to automaticaly autoscale. Maybe from adding a code to its startfunction???
Akzeptierte Antwort
Weitere Antworten (5)
Ilham Hardy
am 17 Jan. 2012
0 Stimmen
By clicking the binocular button on the scope, perhaps?
2 Kommentare
Raldi
am 17 Jan. 2012
Mandip Regmi
am 20 Mai 2020
I did not find the binocular button too
TAB
am 18 Jan. 2012
Add below piece of code in your 'StopFcn' callback function. When the simulation is completed, it will open and autoscale all the scopes in the model.
[EDITED TO WORK FOR MULTIPLE INPUT SCOPE]
bh=find_system(gcs,'FindAll','on','BlockType','Scope');
for x=1:length(bh) %close all scope
set_param(bh(x),'Open','off');
end
for x=1:length(bh)
set_param(bh(x),'Open','on');
fh=gcf;
AxesInScope = findall(fh,'type','axes');
for y=1:length(AxesInScope)
set(fh,'CurrentAxes',AxesInScope(y));
xlim('auto');
ylim('auto');
end
end
6 Kommentare
Raldi
am 18 Jan. 2012
Ilham Hardy
am 18 Jan. 2012
On your simulink model goto: File>>Model properties>>Callbacks>>StopFcn
TAB
am 18 Jan. 2012
You can insert this code in the 'StopFcn' callback function of model.
[1] Open Your Model
[2] Goto File -> Model Properties
[3] Click on callback Tab in Model Properties window
[4] Select 'StopFun' on left side of window
[5] Paste the above code in Text box.
The code will be executed when the simulation stops (after completion or using stop button).
Once simulation is stoped, all the scopes in model will be opened and autoscaled automatically.
Raldi
am 18 Jan. 2012
Raldi
am 18 Jan. 2012
TAB
am 18 Jan. 2012
As your scope is reading 2 inputs, previous code was autoscaling only one graph keeping other as it is.
I have updated the code so that it can work for multiple input scopes.
Andreas Goser
am 18 Jan. 2012
0 Stimmen
Typically, when users describe this, they are happy with the Time Scope Block from DSP System Toolbox. Here is the link to the documentation.
Especially, as Raldi is working at a university in the field of Signal Processing, this product should be available. Note that previous versions used different names like Signal Processing Blockset or DSP Blockset.
4 Kommentare
Raldi
am 18 Jan. 2012
Andreas Goser
am 18 Jan. 2012
Well, then you might need to write your own block (s-function).
Raldi
am 18 Jan. 2012
Raldi
am 18 Jan. 2012
Mingli ZHU
am 22 Apr. 2021
Bearbeitet: Mingli ZHU
am 22 Apr. 2021
0 Stimmen
set(0, 'showhiddenhandles', 'on')
%current graphic object
scope=gcf;
%find Autoscale object
scale=findobj(gcf, 'Tag', 'uimgr.uisplittool_Autoscale');
%click this object
feval(get(scale,'Callback'),scale,[]);
%find PrintToFigure Menu
fig=findobj(gcf, 'Tag', 'uimgr.uimenu_PrintToFigure');
%Click this Menu
feval(get(fig,'Callback'),fig,[]);
set(0, 'showhiddenhandles', 'off')
Jessy Mathault
am 27 Aug. 2021
This function:
simscope('ScopeBar', 'ActionIcon', 'Find', scope(i))
Doesn't seem to be supported anymore in MATLAB 2020b.
This seems to work:
allAxes = findall(gcf,'type','axes');
for x = 1:numel(allAxes)
axis(allAxes(x), 'auto y');
axis(allAxes(x), 'auto x');
end
Kategorien
Mehr zu Interactive Model Editing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!