Hello,
How can I construct a contour map as follows that shows the Ocean depths at a particular location, using Longitude, Latitude and Depth data. (Attached sample xlsx file)
I've been struggling to get something at least slightly similar and I have posted a few posts before this. I'm still learning MATLAB and this has been a dead end for me for some time now. So, literally ANY suggestion, recommendation or help is appreciated.
Now, Do I need more data? Or do I have to have a specific toolbox?
To clarify, I don't mind having different colors or a color bar than the one I have posted. My concern is getting the contour map generated as shown on the post.
Basically, the data refers to Lat, Lon and Depth/Altitude. I am interested in generatnig a contour map that shows different depths/altitudes based on that data set.
I'll add all my previous posts and reference here, to know what my intensions are.
Thank you in advance!

 채택된 답변

darova
darova 2020년 4월 23일

1 개 추천

Use griddata
% lat, long, depth - your data
[LAT,LON] = meshgrid(lat,long); % create 2D matrices
DP = griddata(lat,long,depth,LAT,LON); % calculate value at each grid point
contourf(LAT,LON,DP)

댓글 수: 6

Jake
Jake 2020년 4월 23일
Thank you! Your code is clear but why do I get a figure like this?
Sorry, my bad. Try this:
% lat, long, depth - your data
lat1 = linspace(min(lat),max(lat),20);
lon1 = linspace(min(lon),max(lon),20);
[LAT,LON] = meshgrid(lat1,lon1); % create 2D matrices
DP = griddata(lat,long,depth,LAT,LON); % calculate value at each grid point
contourf(LAT,LON,DP)
Jake
Jake 2020년 4월 23일
편집: Jake 2020년 4월 23일
Great! I think this is what I was looking for!
I shall, however, re-modify this accordingly. Would you recommend any references or pointers that I can follow to modify these outputs? Like adding legends, changing colors, adding labels etc. (Pardon me for the rookie question)
Thank you so much!
What do you mean exactly?
surf(LAT,LON,DP,'facecolor','r') % change all surface color to 'red'
legend('my data') % add legend
colorbar % turn on colorbar
xlabel('X axis') % show axis label
ylabel('Y axis')
MATLAB has good help page. I use it all the time
Jake
Jake 2020년 4월 23일
This is exactly what I meant! I honestly didn't expect a code from you because I already took a lot of your time :)
Thanks a bunch. This saved the day!
Ke Wei Ong
Ke Wei Ong 2020년 8월 15일
May I know what is the unit in the legend, is it in meter or milimeter?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

질문:

2020년 4월 23일

댓글:

2020년 8월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by