Making a counter out of cycling data for a quasi-realtime plot

1 visualización (últimos 30 días)
Caleb
Caleb el 6 de Ag. de 2013
Consider the following dummy data from testing a battery:
%%Data
t = 1:1:100; t = t';
shape = [1 2 3 4 5 5 4 3 2 1]';
voltage = [shape; shape; shape; shape; shape; shape; shape; shape; shape; shape];
cycle = 10*ones(10,1);
intCycle = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10];
%%Quasi-realtime plot
% loop for time-dependent measurements
n = numel(time);
figure, xlim([min(time) max(time)]), ylim([-1.5 5]), xlabel('time (s)'), ylabel('voltage (V)');
hold on
% plot first point
h(1) = plot(time(1), voltage(1));
handles.slider = uicontrol('style', 'slider',...
'position', [350 10 200 20], ...
'min', 0, 'max', 60, ...
'sliderstep',[0.1 0.1], 'value', 10);
slidervalue = get(handles.slider, 'value');
refreshRate = 1/slidervalue;
% loop for cycle-dependent measurements
m = numel(cycle);
figure, xlim([0 numel(cycle)]), ylim([0 max(voltage)]), xlabel('Cycle #'), ylabel('voltage (V)');
hold on
% plot first point
h(2) = plot(intCycle(1), voltage(1));
set(h(4), 'color', 'magenta');
for i = 1:n-1
% time dependent
set(h(1), 'XData', time(1:i), 'YData', voltage(1:i));
drawnow;
pause(refreshRate);
slidervalue = get(handles.slider, 'value');
refreshRate = 1/slidervalue;
end
hold off
What I want to do is plot the voltage at the end of each cycle. Each cycle is 10 seconds long in this example, but the cycle length will most likely never be constant, so there needs to be a way (probably within the loop) to check if the time in cycle(i,1) is complete. Once one cycle is complete, I want one data point plotted on the axis in figure 2.
So, the way it should go in this example is that 10 points are plotted with respect to time in figure 1 for every 1 point plotted with respect to cycle in figure 2.
  4 comentarios
Caleb
Caleb el 6 de Ag. de 2013
More rigorously, let's assume the first 2 values of the cycle array are this:
cycle(1) = 4
cycle(2) = 12
Then the code needs to plot a point at the end of cycle(1), which corresponds to time(4), and a point at cycle(2), which corresponds to time(16).
dpb
dpb el 6 de Ag. de 2013
How did you get that again????
Are you simply looking for a way to determine your "signal" has crossed a threshold rising and falling to use as a flag for the second plot?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Polar Plots 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