how to plot 3d surface maps? interpolation?

42 views (last 30 days)
Lilya
Lilya on 11 Feb 2026 at 8:43
Commented: Lilya ongeveer 3 uur ago
Hi All,
i am struggeling to have a correct interpolation (IDW) for 3d surface maps for the spatial analysis of the parameters collected by CTD to plot temperature (as an example). There is something wrong!
any help is very much appreciated
the steps are below:
1- list of mat fiels each of this mat files contains T table inside (screenshot shows).
2- download the mat fiels
3- grid the data from mulitple CTD locations
4- Surface maps with the coastlines
dataDir = '/';
files = dir(fullfile(dataDir, '*.mat'));
T_all = table();
for i = 1:length(files)
fname = fullfile(dataDir, files(i).name);
S = load(fname);
if isfield(S,'T')
Ti = S.T;
Ti.SourceFile = repmat(string(files(i).name), height(Ti), 1);
Tall = [Tall; Ti];
else
warning('%s does not contain table T', files(i).name)
end
end
depth_target = 2.0; % meters
tol = 0.5; % ±0.5 m
Tz = Tall(abs(Tall.Depth_m - depth_target) <= tol, :);
[G, station, date] = findgroups(Tz.Station, Tz.Date);
Tmap = table();
Tmap.Station = station;
Tmap.Date = date;
Tmap.Lat = splitapply(@mean, Tz.Lat, G);
Tmap.Lon = splitapply(@mean, Tz.Lon, G);
Tmap.Temp = splitapply(@mean, Tz.Temp_C, G);
min_map_lon = 35.2;
max_map_lon = 37.2;
min_map_lat = 25.1;
max_map_lat = 27.6;
[LonGrid, LatGrid] = meshgrid( ...
linspace(min_map_lon, max_map_lon, 250), ...
linspace(min_map_lat, max_map_lat, 250));
TempGrid = griddata( ...
Tmap.Lon, Tmap.Lat, Tmap.Temp, ...
LonGrid, LatGrid, 'v4'); % IDW
load RS_bathy_gebgo % longitude, latitude, bathy
orient portrait
figure
hold on
m_proj('mercator', ...
'lon',[min_map_lon max_map_lon], ...
'lat',[min_map_lat max_map_lat]);
m_pcolor(longitude, latitude, bathy);
shading interp
colormap(flipud(gray))
caxis([-1200 0])
h = m_pcolor(LonGrid, LatGrid, TempGrid);
set(h,'FaceAlpha',0.85) % transparency so bathy shows
shading interp
colormap(turbo)
m_usercoast('red_sea_f','patch',[0.8 0.8 0.8])
m_grid('contour','on','tickdir','out', ...
'box','fancy','fontsize',10, ...
'linewidth',1,'linestyle','--');
colorbar
ylabel('Latitude','fontsize',16,'fontweight','bold');
xlabel('Longitude','fontsize',16,'fontweight','bold');
  3 Comments
Star Strider
Star Strider on 11 Feb 2026 at 13:58
You appear to be using something other than the Mapping Toolbox functions for this. It seems to have a number of interpolation and surface plotting functions specific to geographic coordinates.
You need to supply the functions you are calling, a link to the third-party toolbox you are using, as well as supplying the data (if possible) to get help with this.
Lilya
Lilya ongeveer 3 uur ago
i am unable to upload fiels.
but it looks like what the screenshot shows

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!