MATLAB Answers

Simulink scope autoscale

조회 수: 100(최근 30일)
Raldi 2012년 1월 17일
답변: Jessy Mathault 2021년 8월 27일 1:28
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???

채택된 답변

Titus Edelhofer
Titus Edelhofer 2012년 1월 18일
Hi Raldi,
assuming the scope blocks are open, the following piece of code does the autoscaling for you:
% find all scope blocks as MATLAB figures:
set(0, 'showhiddenhandles', 'on')
scope = findobj(0, 'Tag', 'SIMULINK_SIMSCOPE_FIGURE');
for i=1:length(scope)
% this is the callback of the "autoscale" button:
simscope('ScopeBar', 'ActionIcon', 'Find', scope(i))
set(0, 'showhiddenhandles', 'off')
  댓글 수: 5
Ignacio 2013년 9월 18일
To make the autoscale function automatically i created a matlab function with the code above. The code will be executed each certain period of time. In my case 3 seconds, i did it with this function and the block clock of Simulink. the function that i have created is this one: -------- function u=scope(y) % find all scope blocks as MATLAB figures: u=0; z=mod(y,3)==0 if(z==1) set(0, 'showhiddenhandles', 'on') scope = findobj(0, 'Tag', 'SIMULINK_SIMSCOPE_FIGURE'); for i=1:length(scope) % this is the callback of the "autoscale" button: simscope('ScopeBar', 'ActionIcon', 'Find', scope(i)) end set(0, 'showhiddenhandles', 'off') end
end ----------- Then, in the clock block i selected 1000 as decimation and i use this code in a "interpreted Matlab function" block just writting "scope" in the label "Matlab function". I drive the output of this function to a scope but this output is not really interesting.
best regards

댓글을 달려면 로그인하십시오.

추가 답변(5개)

Ilham Hardy
Ilham Hardy 2012년 1월 17일
By clicking the binocular button on the scope, perhaps?
  댓글 수: 2
Mandip Regmi
Mandip Regmi 2020년 5월 20일
I did not find the binocular button too

댓글을 달려면 로그인하십시오.

TAB 2012년 1월 18일
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.
for x=1:length(bh) %close all scope
for x=1:length(bh)
AxesInScope = findall(fh,'type','axes');
for y=1:length(AxesInScope)
  댓글 수: 6
TAB 2012년 1월 18일
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
Andreas Goser 2012년 1월 18일
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
Raldi 2012년 1월 18일
i think there is another way, ill try to change its YLim throygh my gui and update it.

댓글을 달려면 로그인하십시오.

Mingli ZHU
Mingli ZHU 2021년 4월 22일
편집: Mingli ZHU 2021년 4월 22일
set(0, 'showhiddenhandles', 'on')
%current graphic object
%find Autoscale object
scale=findobj(gcf, 'Tag', 'uimgr.uisplittool_Autoscale');
%click this object
%find PrintToFigure Menu
fig=findobj(gcf, 'Tag', 'uimgr.uimenu_PrintToFigure');
%Click this Menu
set(0, 'showhiddenhandles', 'off')

Jessy Mathault
Jessy Mathault 2021년 8월 27일 1:28
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');

Community Treasure Hunt

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

Start Hunting!

Translated by