Hi,
I have attached a folder which is my given bathymetric data for a seabed. I want to make this into a surface plot or a contour map. I am new to matlab and have little experience with the software, but understand that it is a good software for this particular problem.
If anyone could assit me with this, that would be great.
Thankyou,
Ruari Skinner

 채택된 답변

Star Strider
Star Strider 2019년 2월 16일

2 개 추천

Try this:
[D,S] = xlsread('Bathymetric data (XYZ).xlsx');
Lon = D(:,1);
Lat = D(:,2);
Dep = D(:,3);
figure
plot3(Lon, Lat, Dep, '.')
grid on
view(35,25)
title('Exploratory Plot')
xLon = linspace(min(Lon), max(Lon), 1E+3);
yLat = linspace(min(Lat), max(Lat), 1E+3);
[X,Y] = meshgrid(xLon, yLat);
zDep = griddata(Lon, Lat, Dep, X, Y);
figure
mesh(X, Y, zDep)
grid on
view(35,25)
title('Mesh Plot')
figure
mesh(X, Y, zDep)
hold on
contour3(X, Y, zDep, 20, 'k', 'LineWidth',2)
hold off
grid on
view(35,25)
title('Mesh Plot With Contours')
This uses the griddata function to create the surface necessary to do the mesh plot. The contour3 plot draws contours. You can specify the contours you want (if you want any at all). I plotted them simply out of my own curiosity.
Experiment to get the result you want.

댓글 수: 8

Ruari Skinner
Ruari Skinner 2019년 2월 16일
Thankyou,
I will try this and get back to you.
Star Strider
Star Strider 2019년 2월 16일
My pleasure.
Ruari Skinner
Ruari Skinner 2019년 2월 16일
Hi,
I am struglging to run this with an Error code stating
>> PrincessParade_bathymetry
Index in position 2 exceeds array bounds (must not exceed 1).
Error in PrincessParade_bathymetry (line 3)
Lat = D(:,2);
Star Strider
Star Strider 2019년 2월 16일
My code runs without error with the data you provided as ‘Bathymetric data (XYZ).xlsx’. Use it and the xlsread call I used.
I have no idea what the problem could be with your code, or your implementation of my code, since you didn’t post it.
Ruari Skinner
Ruari Skinner 2019년 2월 16일
Sorry I had simple spelling error.
Thank you for your support and quick responce, much appreciated.
Ruari
Star Strider
Star Strider 2019년 2월 16일
My pleasure.
If my Answer helped you solve your problem, please Accept it!
Dear Star Strider,
I am using this your example to plot a bathymetric data mine as a 2d map colored using the depth variation. I have used the following commands to read e plot:
[X_bathy, Y_bathy, Z_bathy] = grdread2('file.grd');
[xLon, yLat] = meshgrid(X_bathy,Y_bathy);
figure(20); mesh(xLon, yLat, Z_bathy);
it is plotting but it is a 3d figure. Do you know how can I change for one map format? X and Y are in geographical coordinates in degree, and Z in meter.
I will be very thankful for you help.
Guilherme
Star Strider
Star Strider 2023년 9월 22일
@Guilherme Weber Sampaio de Melo — I do not have the Mapping Toolbox, so I have no experience with it or its functions. This problem used Cartesian coordinates, so I was able to work with it.
You might be able to use the view function (specifically view(0,90)) to get a ‘top-down’ view of the surface that may be map-compatible. (Also, the scatteredInterpolant function may be better than griddata for these problems, so it might be worth experimenting with it to get a more accurate representation of the surface.)

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

추가 답변 (0개)

카테고리

질문:

2019년 2월 16일

댓글:

2023년 9월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by