Azzera filtri
Azzera filtri

How do I make a heat/color map from individual data points?

34 visualizzazioni (ultimi 30 giorni)
Howdy,
I'm relatively new to Matlab and would like to create a heatmap of nitrous oxide concentration with contours over a region kind of like this with a colorbar:
I have latitude, longitude, and nitrous oxide concentration data for specific points.
I know you can use the heatmap function and data from a matrix to make a plot like the one above but I do not know how to fill in the gaps of my individual data points across the region. Any help or methodology is appreciated and let me know if there's anymore information I can provide that might help!

Risposta accettata

AndresVar
AndresVar il 21 Feb 2022
You can interpolate between the points using gridded data interpolation: Interpolate 2-D or 3-D scattered data - MATLAB griddata (mathworks.com)
Then with the interpolated matrix you can display in a few ways:
  3 Commenti
Hunter Adams
Hunter Adams il 22 Feb 2022
dat = xlsread('Book2.xlsx');
stations = dat(:,1);
niskin = dat(:,2);
depth = dat(:,3);
lat = dat(:,4);
lon = dat(:,5);
sal = dat(:,6);
oxy = dat(:,7);
n2o = dat(:,8);
[xq, yq] = meshgrid(-89.5:.25:-88.5, 28.7:.25,30);
vq = griddata(lat,lon,n2o,xq,yq);
vq = griddata(lat,lon,n2o,xq,yq);
mesh(xq,yq,vq)
hold on
plot3(lat,lon,n2o,'-bo')
%pcolor(vq)
%contourf(vq)
pcolor has an error creating/updating surface and contourf creates a blank figure. Do you know what I'm missing? The 3D plot works fine. Just need to make it 2D and give color to the n2o concentration.
AndresVar
AndresVar il 23 Feb 2022
Modificato: AndresVar il 23 Feb 2022
your meshgrid is not right so it returns empty xq and yq
[xq, yq] = meshgrid(-89.5:.25:-88.5, 28.7:.25,30) % comma is wrong
xq = [] yq = []
[xq, yq] = meshgrid(-89.5:.25:-88.5, 28.7:.25:30)
xq = 6×5
-89.5000 -89.2500 -89.0000 -88.7500 -88.5000 -89.5000 -89.2500 -89.0000 -88.7500 -88.5000 -89.5000 -89.2500 -89.0000 -88.7500 -88.5000 -89.5000 -89.2500 -89.0000 -88.7500 -88.5000 -89.5000 -89.2500 -89.0000 -88.7500 -88.5000 -89.5000 -89.2500 -89.0000 -88.7500 -88.5000
yq = 6×5
28.7000 28.7000 28.7000 28.7000 28.7000 28.9500 28.9500 28.9500 28.9500 28.9500 29.2000 29.2000 29.2000 29.2000 29.2000 29.4500 29.4500 29.4500 29.4500 29.4500 29.7000 29.7000 29.7000 29.7000 29.7000 29.9500 29.9500 29.9500 29.9500 29.9500
Btw when you plot you can use
% figure;
% pc1 = pcolor(xq,yq,vq)
% pc1.EdgeColor = 'none';
% pc1.FaceColor = 'interp';

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by