Zoom Triggered changes in a plot

조회 수: 6 (최근 30일)
Rachel Leber
Rachel Leber 2019년 10월 16일
편집: Adam 2019년 10월 17일
I have a long signal with several annotations. I'd like the annotations to be visible only when I zoom in. Is there a way to do that?
I've tried using a callback function with 'ActionPostCallback':
figure()
%plot the signal
plot(t,fsig);
hold on;
h = zoom;
h.ActionPostCallback = @showpks;
h.Enable = 'on';
function showpks(obj,evd,s)
%mark the peaks
plot (t(pks), fsig(pks), '*');
end
but I'm getting the following warning messege:
Warning: An error occurred during the mode callback.
> In matlab.uitools.internal.uimode/fireActionPostCallback (line 16)
In zoom>local2DButtonUpFcn (line 1383)
In zoom>@(o,e)local2DButtonUpFcn(o,e,hMode,buttonDownData) (line 1134)
In hgfeval (line 62)
In matlab.uitools.internal.uimode/modeWindowButtonUpFcn (line 52)
In matlab.uitools.internal.uimode/setCallbackFcn>localModeWindowButtonUpFcn (line 56)
Is there another way of triggering the appearance of markers when zooming in?
  댓글 수: 5
Adam
Adam 2019년 10월 17일
편집: Adam 2019년 10월 17일
h.ActionPostCallback = @showpks;
needs to include the variables you are passing in. I can't remember off the top of my head what arguments that function takes as default, but most callbacks take the source and event data as first two arguments. Assuming they are your h and evd then
h.ActionPostCallback = @(h,evd) showpks( h, evd, t, pks, fsig );
should work as the callback syntax, though there are other syntaxes too.
Rachel Leber
Rachel Leber 2019년 10월 17일
Thank you!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by