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

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 comentarios

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.
Thank you heaps Adam!! It worked!!

Iniciar sesión para comentar.

 Respuesta aceptada

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 comentarios

Thank you so so much! easy and straightforward answer to my long-held problem!
EcoBase
EcoBase el 23 de Feb. de 2020
Editada: EcoBase el 23 de Feb. de 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.
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 );

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Printing and Saving en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de En. de 2020

Comentada:

el 23 de Feb. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by