Condition for Specific Data collection

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 comentarios

Mathieu NOE
Mathieu NOE el 17 de Nov. de 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
Adil Sardar
Adil Sardar el 17 de Nov. de 2020
Thank you for your comment
This data is from the running condition of a system output. I want to select some data as i circle in the graph for this i want to have a general code which select the data like i circle. i don't know what kind of condition or creteria i used to get random data for some time. or we can say that it the direction of voltage or current is changing for some time then save that data or any other condition if you suggest.
thank you

Iniciar sesión para comentar.

 Respuesta aceptada

Mathieu NOE
Mathieu NOE el 17 de Nov. de 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 comentarios

Adil Sardar
Adil Sardar el 18 de Nov. de 2020
Thank you soo much for your help
as i explain that this data is from running condition so there is only one cycle completed so now when i used this code for the updated then i can't get the data like that i will provide the updated list you can check it.
I am sorry for your time but i am trying from 1 month to find the condition my whole work stuck here. kindly help me for finding the solution.
hello
this is an improved code
please try it
tx
[num,txt,raw] = xlsread('Data 1 updated.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;
% first and second derivative
[dvoltage, ddvoltage] = firstsecondderivatives(time,voltage);
% some smoothing ?
N = 100;
dvoltage = myslidingavg(dvoltage, N);
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;
% zero crossing detection of the dvoltage signal
[ind_pos,t0_pos,s0_pos,ind_neg,t0_neg,s0_neg] = crossing_V6(dvoltage,time,threshold,'linear');
figure(1);
subplot(2,1,1),plot(time,voltage,'-b',t0_pos,voltage(ind_pos),'+r');grid
subplot(2,1,2),plot(time,dvoltage,'-b',t0_pos,s0_pos,'+r');grid
% % plot selected portion of data
ind_start = ind_pos(1);
ind_stop = ind_pos(2);
figure(2);
plot(time,voltage,'-b',time(ind_start:ind_stop),voltage(ind_start:ind_stop),'or');grid
Adil Sardar
Adil Sardar el 18 de Nov. de 2020
I am really sorry but there is 2 errors in the code i am attaching the screenshot of the error. one is unrecognized function or variable "myslidingavg".. and the other is in crossing_v6.m (line 38) which show not enough arguments. kindly check it
Mathieu NOE
Mathieu NOE el 18 de Nov. de 2020
ok
I send you back all files . I have no error on my side (R2020b)
Adil Sardar
Adil Sardar el 18 de Nov. de 2020
Thank you
in the previous function myslidingavg.m is missing now it work for Data 1 file.
but shows error in the other two file. will you please generalize it to work on all three file and other files if i get next from my experiment.
Mathieu NOE
Mathieu NOE el 18 de Nov. de 2020
ok
it's not so simple because each case is very specific
I have a hard time finding a criteria that works in all situations
Mathieu NOE
Mathieu NOE el 18 de Nov. de 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;
Adil Sardar
Adil Sardar el 18 de Nov. de 2020
Thank you soo much for your time and help.

Iniciar sesión para comentar.

Más respuestas (1)

Peter Perkins
Peter Perkins el 19 de Nov. de 2020

0 votos

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.

1 comentario

Adil Sardar
Adil Sardar el 19 de Nov. de 2020
Thank you for your suggestion but my problem is not reading the data my problem is to find a condition for selecting some specific data.

Iniciar sesión para comentar.

Categorías

Preguntada:

el 17 de Nov. de 2020

Comentada:

el 19 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by