Hi guys.
I've got another data processing problema . Hope to get some ideas from you.
I'm dealing with a table and it looks like Table I. I've shortened it a bit to show here. Now, based on Table I, I'm going to get the first row when a BSid first appeared and the last row when the same BSid lastly appeared. For example, I'd like to obtain a table which looks like Table II. I've been thinking about this for a while but unfortunately, no good idea has come into my mind.
Any good idea is welcom and thank you in advance.
Table I:
ID Time BSid
59 08:47:31 19
59 08:47:32 19
59 08:47:33 19
59 08:47:34 19
59 08:47:35 22
59 08:47:36 22
59 08:47:37 22
59 08:47:38 22
59 08:47:39 22
59 08:47:45 24
59 08:47:46 24
59 08:47:47 24
59 08:47:48 24
59 08:47:49 24
59 08:47:50 22
59 08:47:51 22
59 08:47:52 22
59 08:48:00 22
59 08:48:01 24
59 08:48:02 24
59 08:48:03 24
59 08:48:04 24
59 08:48:05 24
Table II:
ID Time BSid
59 08:47:31 19
59 08:47:34 19
59 08:47:35 22
59 08:47:39 22
59 08:47:45 24
59 08:47:49 24
59 08:47:50 22
59 08:48:00 22
59 08:48:01 24
59 08:48:05 24

 採用された回答

Adam Danz
Adam Danz 2019 年 11 月 11 日
編集済み: Adam Danz 2019 年 11 月 12 日

0 投票

% Determine where BSid values change
deltaBSid = diff(I.BSid)~=0;
% Create a logical vector identifying the first and last row of each
% consecutive BSid
rowIdx =[true; deltaBSid] | [deltaBSid; true];
% Extract desired rows from table
I(rowIdx,:)

3 件のコメント

Adam Danz
Adam Danz 2019 年 11 月 11 日
Tested with fake table:
I = table([ 19 19 19 19 22 22 22 22 22 22 24 24 24 24 24 24 22 22 22 22 24 24 24 24]','VariableNames', {'BSid'});
QIAO WANG
QIAO WANG 2019 年 11 月 12 日
Really appreciate your idea. It worked perfectly. Thank you for helping me out.
Adam Danz
Adam Danz 2019 年 11 月 12 日
Glad I could help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2018a

質問済み:

2019 年 11 月 11 日

コメント済み:

2019 年 11 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by