How can I compute histogram using three variable
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aristo
el 15 de Ag. de 2017
Comentada: Akira Agata
el 25 de Ag. de 2017
I have three variable, for e.g latitude, longitude and temperature. For each latitude and longitude, I have corresponding temperature value. I want to plot latitude v/s longitude plot in 5 degree x 5 degree grid , with mean temperature value inserted in that particular grid instead of occurring frequency.
0 comentarios
Respuesta aceptada
Akira Agata
el 16 de Ag. de 2017
The strait-forward way to do this will be like this (well, there should be more sophisticated way...). I hope it will be help you somehow!
% Sample data
[latGrid,lonGrid] = meshgrid(25:45,125:145);
T = table(latGrid(:),lonGrid(:),randi([0,35],size(latGrid(:))),...
'VariableNames',{'lat','lon','temp'});
% Discretize with 5 degree
[latGroupID, latEdge] = discretize(T.lat, 25:5:45);
[lonGroupID, lonEdge] = discretize(T.lon, 125:5:145);
% Add 5 degree mesh ID to the table T
[C,~,ic] = unique([latGroupID,lonGroupID],'rows');
T.meshID = ic;
% Calculate mean temperature in 5 degree mesh
Output = table(latEdge(C(:,1))',lonEdge(C(:,2))',...
splitapply(@mean,T.temp,T.meshID),...
'VariableNames',{'latEdge','lonEdge','aveTemp'});
% Visualize the output
heatmap(Output,'latEdge','lonEdge','ColorVariable','aveTemp');
3 comentarios
Akira Agata
el 16 de Ag. de 2017
Maybe your MATLAB is not the latest one. In MATLAB R2015x and R2016a, discretize supports only one output argument. After R2016b, it supports two output arguments. So, please check your MATLAB version.
Akira Agata
el 25 de Ag. de 2017
Hi Aristo-san, by slightly changing the last part of my code to the following, similar heatmap figure can be generated.
h = heatmap(Output,'latEdge','lonEdge','ColorVariable','aveTemp');
h.GridVisible = 'off';
h.CellLabelColor = 'none';
h.Colormap = jet;
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!