www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/WriteElementsofVariableExample.m

    %% Write Elements of Variable  
% Write to the first ten elements of the example |temperature| variable.   

%%  
srcFile = fullfile(matlabroot,'toolbox','matlab','demos','example.nc');
copyfile(srcFile,'myfile.nc');
fileattrib('myfile.nc','+w');
ncid = netcdf.open('myfile.nc','WRITE');
varid = netcdf.inqVarID(ncid,'temperature');
data = [100:109];
netcdf.putVar(ncid,varid,0,10,data);
netcdf.close(ncid);