merge duplicate entries and take average associated columns

1 回表示 (過去 30 日間)
Ilse Heeringa
Ilse Heeringa 2021 年 6 月 10 日
回答済み: KSSV 2021 年 6 月 10 日
I have a question about making a matlabscript out of this excel sheet respresenting activity recognition. Our goal is to merge the numbers representing the activities and take the avarage of each colums representing the features.
In our excel sheet 1=lie, 2=sit, 3=stand and 4= walk. We want to merge these identical valuea, unless they are separated by another value. So for example we want to turn A in B :
A=[1 1 1 2 2 3 3 3 4 4 4 2 2 2 3 ] --> B = [ 1 2 3 4 2 3]. So we don't want to sort each number and then take the unique function. But we want to seperate them by chronilogical order. While merging these numbers together, we also want to take the avarage of the other seperate colums (our features)
In the attachment, you can find an example of a part of our excel sheet.
We hope someone can help us out ;)

回答 (1 件)

KSSV
KSSV 2021 年 6 月 10 日
A=[1 1 1 2 2 3 3 3 4 4 4 2 2 2 3 ];
% B = [ 1 2 3 4 2 3]
B= A(diff([0 A])~=0)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by