How to flip through a bunch of graphs

15 次查看(过去 30 天)
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?

请先登录,再进行评论。

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by