find duplicate values using accumarray() function:

조회 수: 1 (최근 30일)
Nadir  Adam
Nadir Adam 2018년 4월 19일
댓글: Nadir Adam 2018년 4월 23일

I have data that contains longitude,latitude,access point address and signal level. I would like to find duplicate longitude,latitude,access point address, then average the signal level over them, and then replacing the original rows with the new single row. How to do this?

For example (made up data):

Starting data:

if true
33.121,-70.630,aa:91:52:9c:72:21,-80
33.122,-70.631,bb:91:52:9c:72:21,-75
33.123,-70.632,cc:91:52:9c:72:21,-84
33.124,-70.633,dd:91:52:9c:72:21,-57
33.121,-70.630,aa:91:52:9c:72:21,-84
33.122,-70.631,bb:91:52:9c:72:21,-73
end

Would become

if true
33.121,-70.630,aa:91:52:9c:72:21,-82
33.122,-70.631,bb:91:52:9c:72:21,-74
33.123,-70.632,cc:91:52:9c:72:21,-84
33.124,-70.633,dd:91:52:9c:72:21,-57
end
  댓글 수: 1
the cyclist
the cyclist 2018년 4월 19일
How are your data currently stored (e.g. what data type)? Can you post the data, or a small sample that has duplicates?

댓글을 달려면 로그인하십시오.

채택된 답변

Razvan Carbunescu
Razvan Carbunescu 2018년 4월 19일

Using accumarray specifically you could do this by combining with findgroups :

[idx,unique_long,unique_lat,unique_acc] = findgroups(long,lat,acc);
[unique_signal] = accumarray(signal,idx,[],@mean);

In R2018a could also use groupsummary but the data should be in a table:

T = table(long,lat,acc,signal);
GT = groupsummary(T,{'long','lat','acc'},'mean','signal')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by