Chinaunix首页 | 论坛 | 博客
  • 博客访问: 408262
  • 博文数量: 77
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 770
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-09 16:46
文章分类
文章存档

2009年(2)

2007年(8)

2006年(67)

我的朋友

分类: WINDOWS

2006-05-11 14:28:02

function ncexample
% ncexample.m -- "NetCDF Toolbox for Matlab-5" example.
%  ncexample (no argument) is a short example that lists
%   itself, builds a simple NetCDF file, then displays
%   its variables.
 
% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO.
%  All Rights Reserved.
%   Disclosure without explicit written consent from the
%    copyright owner does not constitute publication.
 
% Version of 12-Jun-1997 16:23:04.
type(mfilename)
help(mfilename)
 
% ---------------------- DEFINE THE FILE ------------------ %
ncquiet                                              % No NetCDF warnings.
nc = netcdf('ncexample.nc', 'clobber');              % Create NetCDF file.
nc.description = 'NetCDF Example';                   % Global attributes.
nc.author = 'Dr. Charles R. Denham';
nc.date = 'June 9, 1997';
nc('latitude') = 10;                                 % Define dimensions.
nc('longitude') = 10;
nc{'latitude'} = 'latitude';                         % Define variables.
nc{'longitude'} = 'longitude';
nc{'depth'} = {'latitude', 'longitude'};
nc{'latitude'}.units = 'degrees';                    % Attributes.
nc{'longitude'}.units = 'degrees';
nc{'depth'}.units = 'meters';
% ---------------------- STORE THE DATA --------------------- %
latitude = [0 10 20 30 40 50 60 70 80 90];           % Matlab data.
longitude = [0 20 40 60 80 100 120 140 160 180];
depth = rand(length(latitude), length(longitude));
nc{'latitude'}(:) = latitude;                        % Put all the data.
nc{'longitude'}(:) = longitude;
nc{'depth'}(:) = depth;
nc = close(nc);                                      % Close the file.
% ------------------------ RECALL THE DATA ----------------------- %
nc = netcdf('ncexample.nc', 'nowrite');              % Open NetCDF file.
description = nc.description(:)                      % Global attribute.
variables = var(nc);                                 % Get variable data.
for i = 1:length(variables)
   disp([name(variables{i}) ' =']), disp(' ')
   disp(variables{i}(:))
end
nc = close(nc);                                      % Close the file.
% ----------------------------- DONE ----------------------------- %
阅读(2302) | 评论(0) | 转发(0) |
0

上一篇:GrADS下载安装

下一篇:铁达尼式爱情

给主人留下些什么吧!~~