Binning data inside irregular 2d shape

조회 수: 2 (최근 30일)
Elin Jacobs
Elin Jacobs 2022년 4월 21일
댓글: Elin Jacobs 2022년 4월 22일
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.
load(data.mat)
%plot the outline of the shape
figure
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);
[P1,A1]=ndgrid(h1.XBinEdges(1:end-1),h1.YBinEdges(1:end-1));
ac1 = accumarray([t1bin,p1bin],acV(in_1),[],@sum);
cm1 = [0.650 0.612 0.192];
figure
scatterbar3(P1,A1,ac1,1) %function from file exchange
colormap(cm1)
  댓글 수: 2
Image Analyst
Image Analyst 2022년 4월 21일
Attach screenshot please. Use the green and blue frame icon to insert your image. Don't attach a .fig file.
Elin Jacobs
Elin Jacobs 2022년 4월 22일
Edited above.

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

답변 (0개)

카테고리

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

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by