From aaaf60b2f762ab4cc03823ceecd9795fff2ad3db Mon Sep 17 00:00:00 2001 From: Jacques Grelet <jacques.grelet@ird.fr> Date: Wed, 13 Jan 2010 15:24:01 +0000 Subject: [PATCH] correct permutation for char array --- @netcdf_native/private/read.m | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/@netcdf_native/private/read.m b/@netcdf_native/private/read.m index 81e0990..f036511 100644 --- a/@netcdf_native/private/read.m +++ b/@netcdf_native/private/read.m @@ -176,23 +176,39 @@ for id = 0:nvars-1 end end +% % if var is char and as vertical alignment, transpose it +% % ------------------------------------------------------ +% % if xtype == self.NC_CHAR && (size(s.data__, 1) ~= 1) +% % s.data__ = s.data__'; +% % end +% +% % add internal dimension__ member +% % Because MATLAB uses FORTRAN-style ordering, however, the order of +% % the dimension IDs is reversed relative to what would be obtained +% % from the C API +% % ---------------------------- +% if length(dimids) > 1 +% s.data__ = permute(s.data__, fliplr(1:length(dimids))); +% dimids = fliplr(dimids); +% end + % if var is char and as vertical alignment, transpose it % ------------------------------------------------------ - % if xtype == self.NC_CHAR && (size(s.data__, 1) ~= 1) - % s.data__ = s.data__'; - % end + if xtype == self.NC_CHAR && (size(s.data__', 1) == 1) + s.data__ = s.data__'; - % add internal dimension__ member - % Because MATLAB uses FORTRAN-style ordering, however, the order of + % Because MATLAB uses FORTRAN-style indexing, we need to transpose + % N-D array (k,i,j,...) to (i,j,k,...) however, the order of % the dimension IDs is reversed relative to what would be obtained % from the C API - % ---------------------------- - if length(dimids) > 1 + % If s.data__ is a vector, NetCDF API return vertical vector, + % do nothing, it's OK + % ----------------------------------------------------------------- + elseif length(dimids) > 1 s.data__ = permute(s.data__, fliplr(1:length(dimids))); dimids = fliplr(dimids); end - for dimid = 1:numel(dimids) dimname = netcdf.inqDim(self.nc_id, dimids(dimid)); -- GitLab