Help extracting rows based on unique column 1 data
古いコメントを表示
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 件のコメント
Image Analyst
2022 年 11 月 19 日
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.
Brantosaurus
2022 年 11 月 19 日
移動済み: Voss
2022 年 11 月 19 日
採用された回答
その他の回答 (1 件)
% 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, :)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!