problem with slider to move the plot
Afficher commentaires plus anciens
Hello, I'm writing a project for analizing HRV. In my GUI I'm loading the ECG signal and donig the QRS detection. I've got problem with making a slider to move the plot of ECG. The whole signal is about 10 minutes long, but the plot shows only first 20 seconds. What should I do to make it possible to see though the plot? Is a slider a good idea? Maybe sombody could give me some tips on how to handle the problem?
1 commentaire
Robert Cumming
le 3 Jan 2012
show some of your code and you will get a better response
Réponses (1)
Matt Tearle
le 3 Jan 2012
You could make a slider to control the zoom level of the x-axis, if that's what you mean:
t = linspace(0,10);
y = t.*cos(t);
hf = figure;
ha = axes('position',[0.1,0.2,0.8,0.7]);
plot(ha,t,y)
hs = uicontrol(hf,'units','normalized','position',[0.1,0.05,0.8,0.05],...
'style','slider','max',100,'value',100,'min',10);
cb = @(hobj,edata) set(ha,'xlim',[0,0.1*get(hs,'value')]);
set(hs,'callback',cb)
In practice, of course, you'd probably want a bit more code in the callback, so you should write a proper function to do this, rather than this one-line function handle.
EDIT TO ADD: So you mean more like a scroll wheel? Same principle, just change the callback
t = linspace(0,100,501);
y = t.*cos(t);
hf = figure;
ha = axes('position',[0.1,0.2,0.8,0.7]);
plot(ha,t,y)
set(ha,'xlim',[0,10])
hs = uicontrol(hf,'units','normalized','position',[0.1,0.05,0.8,0.05],...
'style','slider','max',9,'value',0,'min',0);
cb = @(a,b) set(ha,'xlim',[0,10]+10*get(hs,'value'));
set(hs,'callback',cb)
1 commentaire
Olga
le 3 Jan 2012
Catégories
En savoir plus sur Multirate Signal Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!