Data filtering(Cut from half length of index until next index )

2 ビュー (過去 30 日間)
Jaehwi Bong
Jaehwi Bong 2019 年 8 月 14 日
編集済み: Jaehwi Bong 2019 年 8 月 14 日
I have this kind of data. First column and seconds column refer to an index and x value relatively.
data = [1 200; 1 201; 1 202; 1 201; 2 301; 2 313; 2 311; 3 401; 3 452; 3 433; 3 405; 4 504; 4 303; 4 604; 4 703; 5 600; 5 700; 5 606; 5 703; 5 905; 5 444;];
For example, I want to get rid of half rows of each index.
I'd like to have this kind of data that has half length (or tird whatever ratio) of index.
data = [1 200; 1 201; 2 301; 2 313; 3 401; 3 452; 4 604 4 703; 5 600; 5 700; 5 606;];
for i = max(data(:,1));
TF = sum(data(:,1)==i)+sum(data(:,1)==i-1);
%TF2 = sum(data(:,1)==i-1);
data(TF./2+1:TF,:) = [];
end %My code doesn't work at all:(
If anyone can help, it would be greatly appreciated.
Thank you!

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 8 月 14 日
data2 = data(cell2mat(accumarray(data(:,1),...
(1:size(data,1))',[],@(x){x(1:ceil(numel(x)/2))})),:);
  1 件のコメント
Jaehwi Bong
Jaehwi Bong 2019 年 8 月 14 日
編集済み: Jaehwi Bong 2019 年 8 月 14 日
Thank you for your answer!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSignal Attributes and Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by