当前位置:   article > 正文

matlab绘制海表面温度、盐度等要素_matlab app画海洋温度图

matlab app画海洋温度图

一般使用nc文件。

下载文件,读取文件,绘制海表面要素图。

数据源:WOA 2018 (noaa.gov)

代码:

  1. clear;
  2. clc;
  3. source1 = 'woa18_decav_t00_04.nc'; %读取文件
  4. ncdisp(source1); %查阅nc文件信息
  5. boundary = [-180 180 -90 90]; %设置经纬度范围
  6. lon = ncread(source1,'lon'); %查阅经度信息
  7. loncount = length(lon); %查阅经度精度(有多少格点)
  8. lat = ncread(source1,'lat'); %查阅纬度信息
  9. latcount = length(lat); %查阅纬度精度(有多少格点)
  10. time = ncread(source1,'time'); %查阅时间层数信息
  11. ticount = length(time); %查阅时间层数
  12. t = 1;
  13. varname = 't_an'; %根据ncdisp显示的变量输入绘图
  14. lon_scope = find(lon >= boundary(1) & lon <= boundary(2));
  15. lat_scope = find(lat >= boundary(3) & lat <= boundary(4));
  16. lon_number = length(lon_scope);
  17. lat_number = length(lat_scope);
  18. start = [lon_scope(1),lat_scope(1),1,1]; %初始位置
  19. count = [lon_number,lat_number,ticount,1]; %读取范围
  20. stride1 = [1,1,1,1]; %读取步长
  21. sst1 = ncread(source1,varname,start,count,stride1); %读取温度
  22. %sst2 = sst1-273.15; %若数据是开尔文需要转换的话
  23. sst_plot = imrotate(sst1(:,:,t), 90); %旋转矩阵,因为matlab是列优先
  24. SST_plot = flipud(sst_plot);
  25. m_proj('Miller Cylindrical','lat',[boundary(3) boundary(4)],'lon',[boundary(1) boundary(2)]);
  26. %投影并做图
  27. lat_1 = linspace(boundary(3),boundary(4),lat_number);
  28. lon_1 = linspace(boundary(1),boundary(2),lon_number);
  29. [plon,plat] = meshgrid(lon_1,lat_1);
  30. hold on
  31. m_pcolor(plon,plat,SST_plot) %添加画的内容
  32. m_coast('color',[0 0 0],'linewidth',1); %绘制海岸线并填充陆地
  33. m_grid('box','fancy') %添加边框
  34. hold on
  35. title('SST','fontsize',15) %设置标题
  36. colormap jet; %添加colorbar
  37. h = colorbar('h');
  38. set(get(h,'title'),'string','摄氏度℃');

 over!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/856736
推荐阅读
相关标签
  

闽ICP备14008679号