how to plot 3d surface maps? interpolation?

47 visualizzazioni (ultimi 30 giorni)
Lilya
Lilya il 11 Feb 2026 alle 8:43
Commentato: Lilya circa 4 ore fa
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');
  4 Commenti

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by