Separating data into one-second intervals, and finding the maximum data in each interval
Mostrar comentarios más antiguos
I have a 2 column matrix with around1300 data per second and measurements in total between 40-80 seconds, the exact number of data is not certain. I'm trying to print the largest three data and the smallest three values in every second in the matrix I have. I think my algorithm knowledge is insufficient for this. Is there anyone who can help?
load("Green6000X.csv")
b12xtime=Green6000X(:,1);
b12xacc=Green6000X(:,2);
u=0:5:height(b12xtime);
v=zeros(138,1);
for i=1:height(b12xtime)
a=find(b12xtime(:,1)<=i);
b=find(b12xtime(:,1)<=i+1);
t(i,1)=height(a);
s(i,1)=height(b);
% val=abs(s-t);
for x=t(i):s(i)
c(x,1)=b12xacc(x,1);
d=max(c);
b=height(s);
n=height(t);
v(x,1)=d;
if(v(x-1,1)==v(x,1))
v(x-1,1)=0;
end
end
clear c;
end
column= find(v==0);
for i=1:length(column)
column= find(v==0);
v(column(1),:) = [];
end
1 comentario
Emre Can Yilmaz
el 21 de Abr. de 2022
Editada: Image Analyst
el 21 de Abr. de 2022
Respuesta aceptada
Más respuestas (1)
KSSV
el 21 de Abr. de 2022
As you said data is from 40-80 seconds and each second has 1300 data points, you can pick the first 40*1300 rows and reshape the data.
T = readtable('Green6000X.csv') ;
d = reshape(T.(2)(1:40*1300),1300,40) ;
% first three elements of each second
d(:,1:3)
% last three elements of each second
d(:,end-3:end)
% max in each row
max(d,[],2)
3 comentarios
Emre Can Yilmaz
el 21 de Abr. de 2022
KSSV
el 21 de Abr. de 2022
You can get the time step to equal, append NaN's at the end and then use reshape.
Emre Can Yilmaz
el 21 de Abr. de 2022
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!