Making a counter out of cycling data for a quasi-realtime plot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 6 Aug. 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?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Condensed Matter & Materials Physics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!