MATLAB: Transpose on ND array is not defined. Use PERMUTE instead.

3dMATLABmatrixnetcdfpermutetranspose

Hello, I'm trying to convert a .mat file in to netcdf but stuck with the following error Transpose on ND array is not defined. Use PERMUTE instead. Any help would be much appreciated.
input_file= 'tp2d.mat'
output_file='tp2d.nc'
status=system(['rm ',' ',output_file])
ny=508
nx=449
nz=32
load 'tp2d.mat'
nccreate(output_file,'depth','Dimensions',{'r',nx,'c',ny,'z',nz},'Format','classic')
depth=Tp;
sizeofdepth=size(depth)
sizeofdepth =
508 449 32
ncwrite(output_file,'depth',depth')
Error using '
Transpose on ND array is not defined. Use PERMUTE instead.

Best Answer

ncwrite(output_file,'depth', permute(depth, [2 1 3]))