欢迎您 亲爱的书友, |
首页 > 都市职场 > 刑啊警长,你这手法很开门呐!
点击这个书签后,可以收藏每个章节的书签, '阅读进度'可以在个人中心书架里查看

第七十六章:欲盖弥彰

小说:刑啊警长,你这手法很开门呐! 作者:牢固的秋裤 字数:1385 更新时间:2024-12-28 01:09:11
0

【各位观众老爷,父老乡亲们,给大家展示一下本人的劳苦

白天就给补上,四更!】

clc;

clear all;

%%注意变换参数,并做个性化标注,避免重复

file = 'sg625-20240119T0000.ncCF.nc3.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);

% 处理时间数据

timeBase = datenum('1970/01/01');

timeStr = datestr(time(firstIdx) / (24 * 3600) + timeBase, 'yyyy-mm-dd HH:MM:SS');

% 如果需要将时间字符串保存为数组,可以取消以下行的注释

% timeStrArray = str2cell(num2str(timeStr)); % 转换为cell数组以便保存

% 如果需要查看或保存处理后的数据,可以添加相关代码

% 例如,保存数据到新的.mat文件

% save('processedData.mat', 'Lon', 'Lat', 'tempc', 'depthc', 'salic', 'timeStr', 'ZI');

% 此代码运行前需要置入task2环境中(即2运行后才可运行)

ZI=griddata(lonc,latc,depthc,Lon,Lat);

figure

mesh(Lon,Lat,ZI);

set(gca,'zdir','reverse')

xlabel('Longitude')

ylabel('Latitude')

zlabel('Depth (m)')

figure

m_proj('Albers Equal-Area Conic','lon',[-100 -64],'lat',[0 40]);

m_gshhs_c('patch',[0.1 0.1 0.1]);

m_grid('box','fancy','xtick',[-100:3:-64],'ytick',[0:3:40],'tickdir','out','fontsize',12);

hold on

m_plot(lon,lat,'r')

figure

plot(lon,lat)

hold on

plot(lon(1,1),lat(1,1),'.','MarkerEdgeColor','k','MarkerSize',30);

plot(lon(537780,1),lat(537780,1),'.','MarkerEdgeColor','r','MarkerSize',30);

legend('路径','起点','终点')

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)')

{下面的是正确代码}

clc;

clear all;

%%注意变换参数,并做个性化标注,避免重复

%%项目2:读取数据,分析数据特征

file='SG635-20170714T1601_731f_7d45_058f.nc';

ncdisp(file)

lon=ncread(file,'longitude');

lat=ncread(file,'latitude');

lonc=unique(lon);

latc=unique(lat);

sali=ncread(file,'salinity');

temp=ncread(file,'temperature');

den=ncread(file,'density');

depth=ncread(file,'depth');

time=ncread(file,'time');

[Lon,Lat]=meshgrid(lonc,latc);

pres=ncread(file,'pressure');

timec=unique(time);

k=1;

for i=1:537779;

if lon(i,1)==lon(i+1,1);

i=i+1;

else

j(k)=i;

k=k+1;

end

end

j(k)=537780;

for i=1:1499

tempc(i,1)=temp(j(i),1);

end

for i=1:1499

timec(i,1)=time(j(i),1);

end

for i=1:1499

depthc(i,1)=depth(j(i),1);

end

for i=1:1499

salic(i,1)=sali(j(i),1);

end

xztime=zeros(1499,1);

datestr(timec(:)/24/3600+datenum('1970/01/01'));

ZI=griddata(lonc,latc,depthc,Lon,Lat);

%%项目3:绘制轨迹图,注意标注坐标轴和其他说明文字,选择不同的地图投影类型,选择不同的线型和点型

% figure

% mesh(Lon,Lat,ZI);

% set(gca,'zdir','reverse')

% xlabel('Longitude')

% ylabel('Latitude')

% zlabel('Depth (m)')

%

% figure

% m_proj('Albers Equal-Area Conic','lon',[-100 -64],'lat',[0 40]);

% m_gshhs_c('patch',[0.1 0.1 0.1]);

% m_grid('box','fancy','xtick',[-100:3:-64],'ytick',[0:3:40],'tickdir','out','fontsize',12);

% hold on

% m_plot(lon,lat,'r')

%

% figure

% plot(lon,lat)

% hold on

% plot(lon(1,1),lat(1,1),'.','MarkerEdgeColor','k','MarkerSize',30);

% plot(lon(537780,1),lat(537780,1),'.','MarkerEdgeColor','r','MarkerSize',30);

% legend('路径','起点','终点')

% axis equal

% grid on

%

% figure

% plot(datenum(timec(:)/24/3600+datenum('1970/01/01')),depthc)

% dateaxis('x',1,'14-Jul-2017')

% set(gca,'ydir','reverse')

% title('剖面深度变化')

% ylabel('Depth (m)')

【写了一天的代码最后还报错了,心态炸了】

警告: Coastline file D:/fvcompost/m_map/private/gshhs_c.b not found

(Have you installed it? See the M_Map User's Guide for details)

---Using default coastline instead

> 位置:mu_coast>get_coasts (第 427 行)

位置: mu_coast (第 96 行)

位置: m_gshhs_c (第 35 行)

位置: task2 (第 57 行)

Index in position 1 exceeds array bounds. Index must not exceed 428.

出错 task2 (第 66 行)

plot(lon(537780,1),lat(537780,1),'.','MarkerEdgeColor','r','MarkerSize',30);

订阅VIP章节 您的账户余额: 阅读币 | 充值 包月 关闭
《刑啊警长,你这手法很开门呐!》 5 阅读币/千字(开通包月可免费阅读全站作品)
  • 第七十六章:欲盖弥彰

    1385 字/ 阅读币 (折后)

    余额不足
  • 还有 章可订阅 约 阅读币

    (请注意:不含未发布章节)

    余额不足
  • 当您阅读到本书付费章节时
    将直接购买不再提示

    开启自动订阅
订阅VIP章节 您的账户余额: 阅读币 | 充值 关闭
《刑啊警长,你这手法很开门呐!》 5 阅读币/千字(包月会员八折优惠)
您的账户中余额不足,是否充值后再来支持作者?: 去充值>>
如果已完成充值: 请点此加载

本章价格: 阅读币 (折后)
还有 章可购买 约 阅读币(请注意:不含未发布章节)

《刑啊警长,你这手法很开门呐!》读者互动
  • 推荐投票

  • 打赏

这本书写的实在是太棒了,我决定投推荐票支持一下 您剩余推荐票 0
温馨提示:每张推荐票可获得2积分。(投票/打赏以后,需要几分钟时间才能显示出来)
写的真棒,打赏支持一下。 可用打赏金额 阅读币(赠币不可用于打赏)
确认投票
温馨提示:每张推荐票可获得2积分。(投票/打赏以后,需要几分钟时间才能显示出来)

6月小说网 登录免费注册

自动登录忘记密码

无需注册,即可登录