How to flip through a bunch of graphs

12 vues (au cours des 30 derniers jours)
Patrick Lydon
Patrick Lydon le 29 Juin 2017
Commenté : Patrick Lydon le 5 Juil 2017
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 commentaires
Patrick Lydon
Patrick Lydon le 30 Juin 2017
I'm sorry Walter but I am unsure of what you described. Where is your comment?
Patrick Lydon
Patrick Lydon le 30 Juin 2017
Oh excuse me, I see it now

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Juin 2017
"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 commentaires
Walter Roberson
Walter Roberson le 4 Juil 2017
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 le 5 Juil 2017
Thank you Walter for all of your help

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by