count the values based on ID and create a new matrix

조회 수: 1 (최근 30일)
nlm
nlm 2019년 2월 10일
댓글: nlm 2019년 2월 10일
Input:
LAT LON VALUE
12.4 91.4 4
31.4 45.6 1
45.9 91.5 2
18.4 96.4 3
11.4 75.6 2
25.9 51.5 4
12.4 91.4 4
31.4 45.6 2
45.9 91.5 2
As you can see some of the lat lon's are repeated with different values, so I want to know for a lat lon, how many times (count) a values is observed. I have a input matrix of (90,000, 3)
LAT LON cnt = 1 cnt=2 cnt=3 cnt =4
12.4 91.4 0 0 1 2
31.4 45.6 1 1 0 0
45.9 91.5 0 1 2 0
18.4 96.4 0 0 1 0
11.4 75.6 0 1 0 0
25.9 51.5 0 0 0 1
I tried table, I could not figure out.
  댓글 수: 9
madhan ravi
madhan ravi 2019년 2월 10일
Well good then :
t=[12.4 91.4 4
31.4 45.6 1
45.9 91.5 2
18.4 96.4 3
11.4 75.6 2
25.9 51.5 4
12.4 91.4 4
31.4 45.6 2
45.9 91.5 2];
T=array2table(t,'VariableNames',{'LAT','LON','COUNT'})
groupsummary(T,{'LAT','LON','COUNT'}) % gives almost your result but in more compact way
nlm
nlm 2019년 2월 10일
I have already tried it, as mentioned earlier. It does not give me the form that I'm looking for. I need it like this
LAT LON cnt = 1 cnt=2 cnt=3 cnt =4
12.4 91.4 0 0 1 2
31.4 45.6 1 1 0 0
45.9 91.5 0 1 2 0
18.4 96.4 0 0 1 0
11.4 75.6 0 1 0 0
25.9 51.5 0 0 0 1

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

답변 (1개)

Image Analyst
Image Analyst 2019년 2월 10일
Use unique() to get unique rows. Then for each unique row (lat,lon combination), call histogram.
  댓글 수: 3
Image Analyst
Image Analyst 2019년 2월 10일
Hist is an object. Look at it's properties and methods and you'll know what to do. Take the semicolon off of that line to see the properties.
nlm
nlm 2019년 2월 10일
편집: nlm 2019년 2월 10일
I did, doesn't help.
Error in matlab.graphics.chart.primitive.Histogram/get.BinCounts

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

카테고리

Help CenterFile Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by