changeset 11805:6db06246dba3 octave-forge

fix bug in ncread and ncwrite for handling scalars
author abarth93
date Sat, 15 Jun 2013 20:16:22 +0000
parents 8ef2f2f69402
children ccd1a4b7a0db
files main/octcdf/inst/ncread.m main/octcdf/inst/ncwrite.m
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/main/octcdf/inst/ncread.m	Sat Jun 15 20:00:15 2013 +0000
+++ b/main/octcdf/inst/ncread.m	Sat Jun 15 20:16:22 2013 +0000
@@ -31,7 +31,12 @@
 
 % ndmat number of dimension for matlab/octave
 
-if nd == 1
+if nd == 0
+  ndmat = 2;
+  start = [1 1];
+  count = [1 1];
+  stride = [1 1];  
+elseif nd == 1
   ndmat = 2;
   start = [1 start];
   count = [1 count];
@@ -97,7 +102,7 @@
   if length(count) < 2
     count(2) = 1; 
   end
-  
+
   x = reshape(x,count);
 end
 
--- a/main/octcdf/inst/ncwrite.m	Sat Jun 15 20:00:15 2013 +0000
+++ b/main/octcdf/inst/ncwrite.m	Sat Jun 15 20:16:22 2013 +0000
@@ -28,6 +28,22 @@
   stride = ones(1,nd);
 end
 
+% ndmat number of dimension for matlab/octave
+
+if nd == 0
+  ndmat = 2;
+  start = [1 1];
+  count = [1 1];
+  stride = [1 1];  
+elseif nd == 1
+  ndmat = 2;
+  start = [1 start];
+  count = [1 count];
+  stride = [1 stride];
+else
+  ndmat = nd;
+end 
+
 % end index
 
 endi = start + (sz-1).*stride;