The ability to increase NC_MAX_DIMS constant is not available in MATLAB 7.9 (R2009b).
Note that you can have multiple variables share one dimension, instead of specifying one dimension per variable. If you know what is the length of the longest vector you would like to put into the netCDF file, you can specify the dimension length to be at least as long as the length of the longest vector, or make a dimension unlimited, as in the example below:
nc = netcdf.create('testfile.nc', netcdf.getConstant('NC_CLOBBER'));
unlim_id = netcdf.defDim(nc, 'unlim', netcdf.getConstant('NC_UNLIMITED'));
varid1 = netcdf.defVar(nc, 'x', 'double', unlim_id);
varid2 = netcdf.defVar(nc, 'y', 'double', unlim_id);
netcdf.endDef(nc);
netcdf.putVar(nc, varid1,0,3, [1 2 3]);
netcdf.putVar(nc, varid2,0,100,rand(100,1));
Best Answer