Zoom Triggered changes in a plot

3 vues (au cours des 30 derniers jours)
Rachel Leber
Rachel Leber le 16 Oct 2019
Modifié(e) : Adam le 17 Oct 2019
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 commentaires
Adam
Adam le 17 Oct 2019
Modifié(e) : Adam le 17 Oct 2019
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 le 17 Oct 2019
Thank you!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Data Exploration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by