⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fill_dim.m

📁 读取Network Common Data Form (netCDF)数据
💻 M
字号:
function str = fill_dim(cdfid, ndims)%  FILL_DIM fills a row of an array with name of a dimension.%--------------------------------------------------------------------%     Copyright (C) J. V. Mansbridge, CSIRO, january 24 1992%     Revision $Revision: 1.3 $% CHANGE   1.2 92/03/10%  function str = fill_dim(cdfid, ndims)%% DESCRIPTION:%  This function fills the ith row of an array named 'str', with the%  the name of the ith dimension in the netcdf file with id number%  cdfid.  ndims is the number of dimensions.  Each dimension name is%  initially allowed up to max_le letters but the number of columns in%  'str' will be expanded if necessary.% % INPUT:%  cdfid: the id number of the netCDF file under consideration.%  ndims: the number of dimensions of the netCDF file under consideration.%% OUTPUT:%  str: the array that receives each dimension name as one of its rows.%% EXAMPLE:%%% CALLER:   general purpose% CALLEE:   none%% AUTHOR:   J. V. Mansbridge, CSIRO%---------------------------------------------------------------------%     Copyright (C), J.V. Mansbridge, %     Commonwealth Scientific and Industrial Research Organisation%     Revision $Revision: 1.3 $%     Author   $Author: mansbrid $%     Date     $Date: 2000/05/01 07:22:17 $%     RCSfile  $RCSfile: fill_dim.m,v $% @(#)fill_dim.m   1.2   92/03/10% %--------------------------------------------------------------------% First try to fill each row of str with the relevant name.  If any% name has more than max_le characters then the the number of characters% in the longest name will be stores and become the number of columns% when the operation is done correctly.str = [];max_le = 25;new_max = 25;for i = 0:ndims - 1   [dimnam, dimsiz, rcode] = ncmex('ncdiminq', cdfid, i);   if rcode == -1     error(['** ERROR ** ncdiminq: rcode = ' num2str(rcode)])   end   le = length(dimnam);   if le > max_le | new_max > max_le       new_max = max ([ le new_max ]);   else      str_tmp = [ dimnam ];      while le < max_le         str_tmp = [ str_tmp ' ' ];         le = le + 1;      end      str = [ str ; str_tmp ];   endend% If any name is more than max_le characters long then store the names% correctly in str now that we know the length of the longest name.if new_max > max_le   str = [];   max_le = new_max;   for i = 0:ndims - 1      [dimnam, dimsiz, rcode] = ncmex('ncdiminq', cdfid, i);      if rcode == -1	error(['** ERROR ** ncdiminq: rcode = ' num2str(rcode)])      end      le = length(dimnam);      str_tmp = [ dimnam ];      while le < max_le         str_tmp = [ str_tmp ' ' ];         le = le + 1;      end      str = [ str ; str_tmp ];   endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -