how to get a mean Z value inside a certain area I set on a plot
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I left the same question a long ago, but I haven't solved the problem yet.
I have a plot as below;

I'd like to get a mean value of all Z values in a paricular area I set on the plot, for example, in the white circle in the figure below;

I wish to know how to set a certain area (draw manually?) and get a mean of all Z values in the area.
Can anyone help me out with this?
I really appreciate your help in advance!
Attached is the original Matlab figure file.
2 commentaires
Adam
le 30 Jan 2020
If you have the image processing toolbox you can draw polygons using
doc Polygon
which also has a function
createMask
which can be used to extract the points inside that polygon, then you can take the mean in the obvious way.
Réponse acceptée
darova
le 30 Jan 2020
Use this
ind = (Y-65).^2 + (X-85).^2 <= 45^2; % find indices inside a circle
N = sum(ind(:)); % number of indices
Z1 = Z.*ind; % values inside a circle
meanValue = sum(Z1(:))/N;
3 commentaires
darova
le 23 Fév 2020
Indices inside the circle:
ind = (Y-65).^2 + (X-85).^2 <= 45^2; % find indices inside a circle
To use these indices:
N = sum( Z(ind)>10 );
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!