Plot median values in a bin (binned plot)

fid = fopen('B0B1_Daytime.txt');
datacell =textscan(fid,'%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f', 'collectoutput', true);
M=datacell{1,1};
x = (M(:,2));
y = (M(:,1));
z = (M(:,9));
scatter(x,y,2,z,'s','filled')
This is the code that i have written here for the plot of x,y and z as surface plot. as it is attached here.
I want this plot with binned value and each bin should has median values in a bin.

5 comentarios

darova
darova el 29 de Ag. de 2021
I don't understand the question. What does it mean: each bin should has median values in a bin? DO you have a picture?
Arun Kumar Singh
Arun Kumar Singh el 29 de Ag. de 2021
I want binned plot like this as i have attached here but here the values are just plotted with scatter function but i want binned plot of step size 1 on both axis but the value comes under step size of 1 degree they should be median value of all the values in that bin.
For example value occurrs into 0 to 1 degree … they all values should be median first and then this median value should be placed in 0 to 1 degree bin.
darova
darova el 29 de Ag. de 2021
Maybe just griddata?
Arun Kumar Singh
Arun Kumar Singh el 29 de Ag. de 2021
Griddata plots the binned plot but it takes average (mean) but i want Median plot
darova
darova el 29 de Ag. de 2021
Well, it's a problem

Iniciar sesión para comentar.

 Respuesta aceptada

Rik
Rik el 29 de Ag. de 2021

0 votos

You can try gridbin.

I haven't used it myself, but it seems to do what you need.

3 comentarios

Arun Kumar Singh
Arun Kumar Singh el 29 de Ag. de 2021
But again the problem is same that gridbin returns the mean value of all scattered data points within every cell of a grid rather than interpolating or fitting a surface.
but i want median value of all scatterd data points.
Rik
Rik el 30 de Ag. de 2021
The documentation states you can supply any function to be applied to each grid cell, so providing @median should work.
Arun Kumar Singh
Arun Kumar Singh el 1 de Sept. de 2021
thank you it worked

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 29 de Ag. de 2021

Comentada:

el 1 de Sept. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by