Checking if 2D coordinates are within 2D bins then sum Z values

1 Ansicht (letzte 30 Tage)
Hi All,
I'm having some difficulty/confusion with using accumarray. I have some polar coordinate data with a 3rd column of intensity, like so.. (polar azimuth intensity)
37.9181 213.8268 0
39.1213 62.7845 0
39.1213 62.7845 7.5725
I also have my binning set up such that each coordinate is binned to 5degrees, like so.. (polar(0:90) azimuth(0:360), binned by 5deg)
0 0 0
0 5 0
0 10 0
...
5 0 0
5 5 0
5 10 0
I'm having trouble with how to check if my coordinate data is within those bins and summing the intensities.
My hope is to have a matrix with the binned coordinates and summed intensities (from raw data) in the 3rd column.
Any guidance will be much appreciated!
(Currently have R2018b)

Akzeptierte Antwort

Matt J
Matt J am 30 Okt. 2018
Bearbeitet: Matt J am 30 Okt. 2018
pedges=0:5:90;
aedges=0:5:360;
[P,A]=ndgrid(pedges(1:end-1),aedges(1:end-1));
pbin=discretize(data(:,1),pedges);
abin=discretize(data(:,2),aedges);
Ibin = accumarray([pbin,abin],data(:,3),size(P)) ;
result=[P(:),A(:), Ibin(:)]
  1 Kommentar
Benjamin Schuessler
Benjamin Schuessler am 30 Okt. 2018
This is perfect! I didn't even think about using the discretize function... Your help is much appreciated!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Polar Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by