how to write a 3d to netcdf for matlab