Condition for Specific Data collection
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Adil Sardar
le 17 Nov 2020
Commenté : Adil Sardar
le 19 Nov 2020
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.
2 commentaires
Mathieu NOE
le 17 Nov 2020
hello
reading the excel files is no problem but how to select the portion of data of interest (as you described) is not evident
what are the crietria / condition to select this or this particular portion of data ?
that's the main issue and you need to provide a methodology for that.
tx
Réponse acceptée
Mathieu NOE
le 17 Nov 2020
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
8 commentaires
Mathieu NOE
le 18 Nov 2020
hello again
probably my last contribution here
I could more or less find a way for data 1 and 3 , but data 2 is so fuzzy, I doubt someone will find one day a criteria to select the appropriate time slots
hope this was helping a bit somehow
good luck for the future ; I'm stopping here now;
Plus de réponses (1)
Peter Perkins
le 19 Nov 2020
Unless you are using a fairly old version of MATLAB, I strognly recommend that you stay away from xlsread, and use readtable or readtimetable instead.
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!