不是,我写这么差有人看么?
该不会真有人看到这来了吧?
那我真是得佩服你了
补充一下昨晚的代码:
clear;clc;
file = 'sp028-20240924T1629_bd04_e02a_4b5f.nc';
ncdisp(file);
lon = ncread(file, 'longitude');
lat = ncread(file, 'latitude');
sali = ncread(file, 'salinity');
temp = ncread(file, 'temperature');
depth = ncread(file, 'depth');
time = ncread(file, 'time');
pres = ncread(file, 'pressure');
lonc = unique(lon(:));
latc = unique(lat(:));
[Lon, Lat] = meshgrid(lonc, latc);
[~, idxLon] = ismember(lon(:), lonc, 'rows');
[~, firstIdx] = sortrows([idxLon, reshape(1:numel(lon), [], 1)]);
firstIdx = firstIdx(unique(idxLon));
tempc = temp(firstIdx);
depthc = depth(firstIdx);
salic = sali(firstIdx);
timec = time(firstIdx)
timeBase = datenum('1970/01/01');
timeStr = datestr(time(firstIdx) / (24 * 3600) + timeBase, 'yyyy-mm-dd HH:MM:SS');
Z=griddata(lonc,latc,depthc,Lon,Lat);
figure
mesh(Lon,Lat,Z);
set(gca,'zdir','reverse')
title('空间插值图')
xlabel('Longitude')
ylabel('Latitude')
zlabel('Depth (m)')
figure
m_proj('Albers Equal-Area Conic','lon',[-95 -70],'lat',[10 30]);
m_gshhs_c('patch',[0.1 0.1 0.1]);
m_grid('box','fancy','xtick',[-95:3:-70],'ytick',[10:3:30],'tickdir','out','fontsize',12);
title('运动轨迹图')
hold on
m_plot(lon,lat,'r')
figure
plot(lon,lat)
title('路线图')
legend('路径','起点','终点','Location','SouthEast')
hold on
plot(lon(1,1),lat(1,1),'.','MarkerEdgeColor','k','MarkerSize',30);
plot(lon(428,1),lat(428,1),'.','MarkerEdgeColor','r','MarkerSize',30);
axis equal
grid on
figure
plot(datenum(timec(:)/24/3600+datenum('1970/01/01')),depthc)
dateaxis('x',1,'19-Jan-2024')
set(gca,'ydir','reverse')
title('剖面深度变化图')
ylabel('Depth (m)')