필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Problems using a slider to move through plot

조회 수: 1 (최근 30일)
Patrick Lydon
Patrick Lydon 2017년 7월 3일
마감: Walter Roberson 2017년 7월 4일
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.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by