필터 지우기
필터 지우기

How to flip through a bunch of graphs

조회 수: 27 (최근 30일)
Patrick Lydon
Patrick Lydon 2017년 6월 29일
댓글: Patrick Lydon 2017년 7월 5일
Hi,
So I am plotting waveforms that are generated 10 times per second. Each waveform is 500 points. Waveforms are generated throughout the day so I am getting a lot of data at one time (5,000 points per second times 96,000 seconds in a day). I need a way to go through all of these waveforms quickly but not take up too much memory.
My idea is to plot a waveform, erase the waveform, plot the next waveform, erase it, plot the next, erase it etc etc. Almost like flipping through the pages of a phonebook or one of those flip books that have a picture of someone kicking a soccer ball as you flip through it. BUT I am also open to any other ideas on how to shift through large amounts of data. Are there any functions I could use for this? Any help would be appreciated
Thank you
  댓글 수: 5
Patrick Lydon
Patrick Lydon 2017년 6월 30일
I'm sorry Walter but I am unsure of what you described. Where is your comment?
Patrick Lydon
Patrick Lydon 2017년 6월 30일
Oh excuse me, I see it now

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

채택된 답변

Walter Roberson
Walter Roberson 2017년 6월 29일
"My idea is to plot a waveform, erase the waveform, plot the next waveform, erase it, plot the next, erase it etc etc."
Create a plot with appropriate titles and so on, and
h = plot(nan, nan, appropriate_linestyle_etc_here);
Now, for each iteration, instead of erasing the previous waveform, set() the XData and YData parameters of h to the updated values. You could hook that into a timer, or you could hook that into a WindowKeyPressFcn, or you could arrange Forward and Back push buttons, or you could hook it into a slider callback.
You could even hook it into a Pan ActionPostCallback: you would fetch the new zoom limits from the event, pull out the appropriate data range and set the XData and YData properties.
  댓글 수: 5
Walter Roberson
Walter Roberson 2017년 7월 4일
What is hax, and why are you passing it to the callback, and why do you not have position to receive it in the parameters?
Your XData and NDataPoints are not defined in the callback function -- not unless you convert to a nested function with shared variables.
You are not updating YData as you update XData
You permit the slider value to be as large as NDataPoints, and you then multiply the fetched value by NDataPoints, so you could end up with an index as large as NDataPoints^2. That might be too much -- or it might not be enough.
function set_up_slider(x, y1, NDataPoints)
lenx = length(x);
gg = min(lenx, NDataPoints);
h = plot( x(1:gg), y(1, gg), 'k');
if lenx > NDataPoints
uicontrol('Style', 'slider', 'Min', 1, 'Max', lenx, ...
'Value', 1, 'Position', [400 20 120 20], ...
'Callback', @react_to_slider);
end
function react_to_slider(source, event) %nested !!
val = round(get(source, 'Value'));
if val + NDataPoints > lenx
val = lenx - NDataPoints - 1;
end
set(source, 'Value', val);
gg = val + NDataPoints - 1;
set(h, 'XData', x(val : gg), 'YData', y1(val : gg));
end
end
Patrick Lydon
Patrick Lydon 2017년 7월 5일
Thank you Walter for all of your help

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by