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

34 次查看(过去 30 天)
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!

采纳的回答

AndresVar
AndresVar 2022-2-21
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 个评论
Hunter Adams
Hunter Adams 2022-2-22
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 2022-2-23
编辑:AndresVar 2022-2-23
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';

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by