MATLAB: Condition for Specific Data collection

collection;conditiondataexcelgraphspecific data

Hi everyone
I am facing a problem i have different Excel files in which there is a lot of data. i want to find some common condition for all these file to get the specific data (e.g i circle some example in the graph). I also attach 3 excel file as an example. I want to find some condition according to current or volatge column in the excel file. there is 3 column time, voltage and current. you can use any columnn for finding the condition to get some specific data and discard the remaining data. waiting for your kind help.
Thank you.

Best Answer

hello
see example below
this could be interesting for data 1 example
but the two other data it's not feasible unless someone come's with a clever condtion equation to select such fraction of data
[num,txt,raw] = xlsread('Data 1.xlsx') ;
time = num(:,1); % s
current = num(:,2); % A
voltage = num(:,3); % V
samples = length(time);
dt = (time(end)-time(1))/(samples-1);
Fs = 1/dt;
% main loop : extract min max vales for every 5 min data %
[dvoltage, ddvoltage] = firstsecondderivatives(time,voltage);
figure(1);
subplot(2,1,1),plot(time,voltage,'-b');grid
subplot(2,1,2),plot(time,dvoltage,'-b');grid
% selected buffer is defined between the two positive peaks of dvoltage
dvoltage_max = max(dvoltage(dvoltage>0));
threshold = dvoltage_max/2;
ind = find(dvoltage > threshold);
ind_start = ind(1)-100;
ind_stop = ind(end)-100;
% plot selected portion of data
figure(2);
plot(time,voltage,'-b',time(ind_start:ind_stop),voltage(ind_start:ind_stop),'or');grid
function [dy, ddy] = firstsecondderivatives(x,y)
% The function calculates the first & second derivative of a function that is given by a set
% of points. The first derivatives at the first and last points are calculated by
% the 3 point forward and 3 point backward finite difference scheme respectively.
% The first derivatives at all the other points are calculated by the 2 point
% central approach.

% The second derivatives at the first and last points are calculated by
% the 4 point forward and 4 point backward finite difference scheme respectively.
% The second derivatives at all the other points are calculated by the 3 point
% central approach.
n = length (x);
dy = zeros;
ddy = zeros;
% Input variables:
% x: vector with the x the data points.
% y: vector with the f(x) data points.
% Output variable:
% dy: Vector with first derivative at each point.
% ddy: Vector with second derivative at each point.
dy(1) = (-3*y(1) + 4*y(2) - y(3)) / 2*(x(2) - x(1)); % First derivative
ddy(1) = (2*y(1) - 5*y(2) + 4*y(3) - y(4)) / (x(2) - x(1))^2; % Second derivative
for i = 2:n-1
dy(i) = (y(i+1) - y(i-1)) / 2*(x(i+1) - x(i-1));
ddy(i) = (y(i-1) - 2*y(i) + y(i+1)) / (x(i-1) - x(i))^2;
end
dy(n) = (y(n-2) - 4*y(n-1) + 3*y(n)) / 2*(x(n) - x(n-1));
ddy(n) = (-y(n-3) + 4*y(n-2) - 5*y(n-1) + 2*y(n)) / (x(n) - x(n-1))^2;
end
Related Question