Help extracting rows based on unique column 1 data
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brantosaurus
el 19 de Nov. de 2022
Respondida: Campion Loong
el 30 de Nov. de 2022
I have a large MxN matrix of data from which i would like to extract specific rows of data.
The first column of the matrix contains a chronological timebase in seconds, in ascending order.
t1 a1 b1 .. n1
t2 a2 b2 .. n2
:
talpha ..
:
tbeta ..
:
tgamma ..
:
tm am bm .. nm
I know the unique times of 3 events (talpha, tbeta, tgamma) that occur in column 1.
How do i extract the rows in chronological order based on the knowledge of their unique times?
Tried categorical with valueset and ordinal but no luck!
2 comentarios
Image Analyst
el 19 de Nov. de 2022
How large is large? How many GB or rows? If it really is large, like hundreds of millions of rows or several GB of data then you may need to use memmapfile. If you just have a few million rows or less, that's not large.
Respuesta aceptada
Star Strider
el 19 de Nov. de 2022
There is a lot I don’t unerstand about this problem.
However, if you want to find the unique occurrences of each of the ‘talpha’ , ‘tbeta’ and ‘tgamma’ so that they return the indices of the first incidence of each value, use the unique function with the first two outputs (the unique values, and the indices of the first instance of each value) with the 'stable' argument (to prvent sorting the result).
2 comentarios
Más respuestas (1)
Campion Loong
el 30 de Nov. de 2022
% Make some pretend data for your a#/b#/c# numbers
A = rand(10000,1); B = rand(10000,1); C = rand(10000,1);
% Use timetable. Here I assume regular timesteps. If not, use the
% 'RowTimes' N/V pair instead
tt = timetable(A, B, C, 'TimeStep', seconds(1))
If you know the exact time of your unique events
t_alpha = seconds(10);
t_beta = minutes(150);
t_gamma = hours(2);
% Index directly with time. Get all the rows in one go like below, or
% separately as your preferred:
tt([t_alpha; t_beta; t_gamma], :)
Now, if you are not sure the 'exact' time (e.g. your data has some noise)
tt.Time = tt.Time + milliseconds(randn(10000,1)); % mix in some made-up noise
% Exact time index will turn up nothing ...
tt([t_alpha; t_beta; t_gamma], :)
% Use withtol to index with time tolerance:
wt = withtol([t_alpha; t_beta; t_gamma],seconds(0.5))
tt(wt, :)
0 comentarios
Ver también
Categorías
Más información sobre Data Preprocessing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!