How to flip through a bunch of graphs

18 visualizaciones (últimos 30 días)
Patrick Lydon
Patrick Lydon el 29 de Jun. de 2017
Comentada: Patrick Lydon el 5 de Jul. de 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 comentarios
Patrick Lydon
Patrick Lydon el 30 de Jun. de 2017
I'm sorry Walter but I am unsure of what you described. Where is your comment?
Patrick Lydon
Patrick Lydon el 30 de Jun. de 2017
Oh excuse me, I see it now

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Jun. de 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 comentarios
Walter Roberson
Walter Roberson el 4 de Jul. de 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 el 5 de Jul. de 2017
Thank you Walter for all of your help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by