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

20 ビュー (過去 30 日間)
Hunter Adams
Hunter Adams 2022 年 2 月 21 日
編集済み: AndresVar 2022 年 2 月 23 日
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 Center および File ExchangeColor and Styling についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by