Filter löschen
Filter löschen

Binning data inside irregular 2d shape

3 Ansichten (letzte 30 Tage)
Elin Jacobs
Elin Jacobs am 21 Apr. 2022
Kommentiert: Elin Jacobs am 22 Apr. 2022
I have three vectors of data, two representing x-y space (tempV and precV) and one representing z direction (acV). I also have an irregular shape and I want to bin all z data inside the shape (into more than one bin). I also have a logical vector for the datapoints that fall inside the shape. I want to plot the shape and the binned z data as bars. I have tried a number of options but am stuck because my bins in some cases fall outside the shape as the outline is not a rectangular. I'm guessing I need to change the x (P1) and y (A1) location of the z (ac1) data when I plot it, but havent figured out a good way to do so (like bin centers or similar). Below is what I have so far. In the attached figure, the five greenish bars that are closest to the x and y axes are in the wrong location, I want to force them to locations inside the same area as the other four (i.e., the are vaguely delineated by the black lines). Thanks.
%plot the outline of the shape
plot(xv_1,yv_1) % polygon
%bin data and find bin edges
h1 = histogram2(tempV(in_1),precV(in_1),3);
p1bin = discretize(precV(in_1),h1.YBinEdges);
t1bin = discretize(tempV(in_1),h1.XBinEdges);
ac1 = accumarray([t1bin,p1bin],acV(in_1),[],@sum);
cm1 = [0.650 0.612 0.192];
scatterbar3(P1,A1,ac1,1) %function from file exchange
  2 Kommentare
Image Analyst
Image Analyst am 21 Apr. 2022
Attach screenshot please. Use the green and blue frame icon to insert your image. Don't attach a .fig file.
Elin Jacobs
Elin Jacobs am 22 Apr. 2022
Edited above.

Melden Sie sich an, um zu kommentieren.

Antworten (0)




Community Treasure Hunt

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

Start Hunting!

Translated by