Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Problems using a slider to move through plot

1 visualizzazione (ultimi 30 giorni)
Patrick Lydon
Patrick Lydon il 3 Lug 2017
Chiuso: Walter Roberson il 4 Lug 2017
I am having troubles adding a slider to a plot, and I believe the problem is in the callback function. I have many waveforms of 500 points each that I want to plot and be able to slide through. I have all of the x points in one array and all the y points in the other. Every 500 elements in the arrays are another waveform. I have been working on this all day and am really confused by the callback function at this point. I will attach my full code, but here is a specific snip it of the code:
if true
x=zeros(1,(NSubset*NDataPoints));
index=1;
for j= 1:NSubset;
for t=0:(0.01/NDataPoints):0.01;
if t~=0.01;
x(1,index)=RelativeTime(1,j)+t;
index=index+1;
else
end
end
end
y1=zeros(1,(NSubset*NDataPoints));
ind=1;
for h=1:NSubset;
for p=1:NDataPoints;
y1(1,ind)=channel4(h,p);
ind=ind+1;
end
end
tt=1;
gg=NDataPoints;
h=plot(x(1,tt:gg),y1(1,tt:gg),'k');
uicontrol('Style', 'slider',...
'Min',1,'Max',NDataPoints,'Value',1,...
'Position', [400 20 120 20],...
'Callback', @sliderCallback);
function sliderCallback(source,~)
val = get(source, 'Value');
set(f,'XData',XData(1,(NDataPoints*val)-(NDataPoints-1):NDataPoints*val));
end
NDataPoints is thenumber of points per waveform. and NSubset is the number of waveforms.

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by