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

2 visualizaciones (últimos 30 días)
EcoBase
EcoBase el 24 de En. de 2020
Comentada: darova el 23 de Feb. de 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 comentarios
Adam
Adam el 30 de En. de 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 el 23 de Feb. de 2020
Thank you heaps Adam!! It worked!!

Iniciar sesión para comentar.

Respuesta aceptada

darova
darova el 30 de En. de 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 comentarios
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.
darova
darova el 23 de Feb. de 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 );

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by