%% Write Data with Specified Spacing
% Write data with specified spacing between the variable indices along each dimension.
% First, create a file myncfile.nc with an empty 6-by-6 numeric variable vmark. To disable the default fill value for missing or empty variables, set the value of the FillValue name-value pair argument to disable.

nccreate('myncfile.nc','vmark',...
         'Dimensions', {'x',6,'y',6},...
         'FillValue','disable'); 

% Next, write a 3-by-3 numeric array to the variable vmark starting at the location [1 1] with a spacing of 2 between the variable indices along each dimension. Read and display vmark from the file.

ncwrite('myncfile.nc','vmark',3*eye(3),[1 1],[2 2]);
varData = ncread('myncfile.nc','vmark');
display(varData)

% Copyright 2018 The MathWorks, Inc.