how to count the number of scatter points in a each sector region of the 6 concentric circles ?

1 Ansicht (letzte 30 Tage)
I have found the scatter points in a graph but i need to find the number of scatter points lies inside of the sector region of the circle in the form of percentage ? i have attached the sample answer graph for this question(fig2).
scatter graph

Akzeptierte Antwort

Image Analyst
Image Analyst am 5 Dez. 2022
If you have the x and y points then you can get the angle of each point using atand
angles = atand(y ./ x)
Then you can take the histogram
counts = histcounts(angles, 8)
percents = 100 * counts / numel(x)
  2 Kommentare
Image Analyst
Image Analyst am 5 Dez. 2022
Bearbeitet: Image Analyst am 5 Dez. 2022
What does each row and column represent? For example if column 1 is x and column 2 is y, what do the other 199 columns represent?
Attach your matrix with the paperclip icon.
So do you want a count for each radius range and each of 4 angle sectors. Then you need to compute the radius of each point.
radii = sqrt(x.^2 + y.^2);
and compute edges for the angles and radii and then use
help histogram2
HISTOGRAM2 Plots a bivariate histogram. HISTOGRAM2(X,Y) plots a bivariate histogram of X and Y. X and Y can be arrays of any shape, but they must have the same size. HISTOGRAM2 determines the bin edges using an automatic binning algorithm that returns uniform bins of an area chosen to cover the range of values in X and Y and reveal the shape of the underlying distribution. HISTOGRAM2(X,Y,NBINS), where NBINS is a scalar or 2-element vector, specifies the number of bins to use. A scalar specifies the same number of bins in each dimension, whereas the 2-element vector [nbinsx nbinsy] specifies a different number of bins for the X and Y dimensions. HISTOGRAM2(X,Y,XEDGES,YEDGES), where XEDGES and YEDGES are vectors, specifies the edges of the bins. The value [X(k),Y(k)] is in the (i,j)th bin if XEDGES(i) <= X(k) < XEDGES(i+1) and YEDGES(j) <= Y(k) < YEDGES(j+1). The last bins in the X and Y dimensions will also include the upper edge. For example, [X(k),Y(k)] will fall into the i-th bin in the last row if XEDGES(end-1) <= X(k) <= XEDGES(end) && YEDGES(i) <= Y(k) < YEDGES(i+1). HISTOGRAM2(...,'BinWidth',BW) where BW is a scalar or 2-element vector, uses bins of size BW. A scalar specifies the same bin width for each dimension, whereas the 2-element vector [bwx bwy] specifies different bin widths for the X and Y dimensions. To prevent from accidentally creating too many bins, a limit of 1024 bins can be created along each dimension when specifying 'BinWidth'. If BW is too small such that more than 1024 bins are needed in either dimension, HISTOGRAM2 uses larger bins instead. HISTOGRAM2(...,'XBinLimits',[XBMIN,XBMAX]) plots a histogram with only elements between the bin limits inclusive along the X axis, X>=BMINX & X<=BMAXX. Similarly, HISTOGRAM2(...,'YBinLimits',[YBMIN,YBMAX]) uses only elements between the bin limits inclusive along the Y axis, Y>=YBMIN & Y<=YBMAX. HISTOGRAM2(...,'Normalization',NM) specifies the normalization scheme of the histogram values. The normalization scheme affects the scaling of the histogram along the Z axis. NM can be: 'count' The height of each bar is the number of observations in each bin. The sum of the bar heights is generally equal to NUMEL(X) and NUMEL(Y), but is less than if some of the input data is not included in the bins.. 'probability' The height of each bar is the relative number of observations (number of observations in bin / total number of observations), and the sum of the bar heights is less than or equal to 1. 'countdensity' The height of each bar is, (the number of observations in each bin) / (area of bin). The volume (height * area) of each bar is the number of observations in the bin, and the sum of the bar volumes is less than or equal to NUMEL(X) and NUMEL(Y). 'pdf' Probability density function estimate. The height of each bar is, (number of observations in bin) / (total number of observations * area of bin). The volume of each bar is the relative number of observations, and the sum of the bar volumes is less than or equal to 1. 'cumcount' The height of each bar is the cumulative number of observations in each bin and all previous bins in both the X and Y dimensions. The height of the last bar is less than or equal to NUMEL(X) and NUMEL(Y). 'cdf' Cumulative density function estimate. The height of each bar is the cumulative relative number of observations in each bin and all previous bins in both the X and Y dimensions. The height of the last bar is less than or equal to 1. HISTOGRAM2(...,'DisplayStyle',STYLE) specifies the display style of the histogram. STYLE can be: 'bar3' Display histogram using 3-D bars. This is the default. 'tile' Display histogram as a rectangular array of tiles with colors indicating the bin values. HISTOGRAM2(...,'BinMethod',BM), uses the specified automatic binning algorithm to determine the number and width of the bins. BM can be: 'auto' The default 'auto' algorithm chooses a bin size to cover the data range and reveal the shape of the underlying distribution. 'scott' Scott's rule is optimal if X and Y are close to being jointly normally distributed, but is also appropriate for most other distributions. It uses a bin size of [3.5*STD(X(:))*NUMEL(X)^(-1/4) 3.5*STD(Y(:))*NUMEL(Y)^(-1/4)] 'fd' The Freedman-Diaconis rule is less sensitive to outliers in the data, and may be more suitable for data with heavy-tailed distributions. It uses a bin size of [2*IQR(X(:))*NUMEL(X)^(-1/4) 2*IQR(Y(:))*NUMEL(Y)^(-1/4)] where IQR is the interquartile range. 'integers' The integer rule is useful with integer data, as it creates a bin for each pair of integer X and Y. It uses a bin width of 1 along each dimension and places bin edges halfway between integers. To prevent from accidentally creating too many bins, a limit of 1024 bins can be created along each dimension with this rule. If the data range along either dimension is greater than 1024, then larger bins are used instead. HISTOGRAM2(...,NAME,VALUE) set the property NAME to VALUE. HISTOGRAM2('XBinEdges', XEDGES, 'YBinEdges', YEDGES, 'BinCounts', COUNTS) where COUNTS is a matrix of size [length(XEDGES)-1, length(YEDGES)-1], manually specifies the bin counts. HISTOGRAM2 plots the counts and does not do any data binning. HISTOGRAM2(AX,...) plots into AX instead of the current axes. H = HISTOGRAM2(...) also returns a Histogram2 object. Use this to inspect and adjust the properties of the histogram. Class support for inputs X, Y, XEDGES, YEDGES: float: double, single integers: uint8, int8, uint16, int16, uint32, int32, uint64, int64 logical See also HISTCOUNTS2, HISTCOUNTS, HISTOGRAM, DISCRETIZE, matlab.graphics.chart.primitive.Histogram2 Documentation for histogram2 doc histogram2 Other uses of histogram2 matlab.graphics.chart.primitive/histogram2 tall/histogram2

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

KSSV
KSSV am 5 Dez. 2022
Let (x,y) be your scattered points.
C = [mean(x) mean(y)] ; % center of circle. This would be (0,0)
R = 200 ; % RAdius of circle
d = sqrt((C(1)-x).^2+(C(2)-y).^2) ; % distance of each point from circle center
idx = d <= R ; % points lying inside circle of radii R
nR = nnz(idx)*100/length(x) % percentage of points lying inside circle of radius R

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by