how to get a mean Z value inside a certain area I set on a plot

2 vues (au cours des 30 derniers jours)
EcoBase
EcoBase le 24 Jan 2020
Commenté : darova le 23 Fév 2020
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
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.
EcoBase
EcoBase le 23 Fév 2020
Thank you heaps Adam!! It worked!!

Connectez-vous pour commenter.

Réponse acceptée

darova
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
EcoBase
EcoBase le 23 Fév 2020
Modifié(e) : EcoBase le 23 Fév 2020
Just one more question, sorry!
How can I count the number of values (or percentage of area) that are greater than, say 10, inside the circle?
Thank you in advance.
darova
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 );

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by