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

📄 ncrectest.m

📁 MATLAB中读写、处理科学数据文件格式NETCDF的程序
💻 M
字号:
function ncrectest(nrecords)

% ncrectest -- Test of ncrecput/ncrecget.
%  ncrectest(nrecords) exercises the netcdf test-file
%   'foo.cdf' by writing/reading nrecords, using
%   ncrecinq(), ncrecput() and ncrecget().
 
% Copyright (C) 1996 Dr. Charles R. Denham, ZYDECO.
% All Rights Reserved.
 
% Version of 17-Apr-96 at 16:45:57.08.
% Updated    08-Dec-2000 13:58:07.

if nargin < 1, nrecords = 1; end

x = 1:201;

ncid = ncmex('open', 'foo.cdf', 'write');

[varids, varsizes, status] = ncrecinq(ncid);

disp(' ## Variable ids and sizes:')
disp([varids; varsizes])

varid = 2;
for recnum = 0:nrecords-1
   status = ncmex('varput', ncid, varid, recnum, 1, 9999);
   [d, status] = ncmex('varget', ncid, varid, recnum, 1);
end

okay = 1;

d = [];
for recnum = 0:nrecords-1
   status = ncrecput(ncid, recnum, x);
   [d, status] = ncrecget(ncid, recnum);
   if any(d(:) ~= x(:))
      disp([' ## Bad round trip: record ' int2str(recnum)])
      okay = 0;
   end
end

status = ncmex('close', ncid);

if okay, disp(' ## Successful test.'), end

⌨️ 快捷键说明

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