필터 지우기
필터 지우기

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

조회 수: 34 (최근 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 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