MATLAB: How to write a netcdf file that ncdump and cdo/GrADS will understand

ncwritenetcdf

I am experimenting with writing netcdf files using nccreate and ncwrite. everything appears to work fine and I can read the resulting netcdf file back into Matlab no problem. But when I try using unix/DOS utilities like ncdump, I'm told "Not a netCDF file". I am trying to import the data into GrADS using cdo (Climate data operators) but strike essentially the same problem. Is there something I'm missing?
My data are sea ice concentrations on a 161×161 grid over the southern oceans and Antarctica. I created the data set using
nccreate('ice_monthly_ps161x161_3d.nc','x','dimensions',{'x',nx},'format','netcdf4')
ncwrite('ice_monthly_ps161x161_3d.nc','x',x)
nccreate('ice_monthly_ps161x161_3d.nc','y','dimensions',{'y',ny})
ncwrite('ice_monthly_ps161x161_3d.nc','y',y)
nccreate('ice_monthly_ps161x161_3d.nc','lat','dimensions',{'x','y'})
ncwrite('ice_monthly_ps161x161_3d.nc','lat',lat)
nccreate('ice_monthly_ps161x161_3d.nc','lon','dimensions',{'x','y'})
ncwrite('ice_monthly_ps161x161_3d.nc','lon',lon)
nccreate('ice_monthly_ps161x161_3d.nc','time','dimensions',{'time',ice.nt})
ncwrite('ice_monthly_ps161x161_3d.nc','time',timenum)
nccreate('ice_monthly_ps161x161_3d.nc','projection','dimensions',{'projection',length(ice.specs)})
ncwrite('ice_monthly_ps161x161_3d.nc','projection',ice.specs)
nccreate('ice_monthly_ps161x161_3d.nc','ice_concentration','dimensions',{'x','y','time'})
ncwrite('ice_monthly_ps161x161_3d.nc','ice_concentration',icef)
where 'icef' is a 3d array of the sea ice data. I can look at the netCDF file with ncinfo and can read it OK with the ncread routine or with the nctoolbox library. But when I use ncdump from the DOS command line I am told this is not a netCDF file.
Am I missing something simple here? Any suggestions appreciated.
[Edit: Formatted code. -AU]

Best Answer

James - my guess is that the other utilities you are using are based on an older version of the NetCDF library - they do not recognize netcdf4 files. netcdf4 is not backwards compatible, hence @Geoff's suggestion to try a different format. Though, I would recommend also trying 'classic'.
More information on the formats is here