From: <aba...@us...> - 2012-07-31 11:34:34
|
Revision: 10789 http://octave.svn.sourceforge.net/octave/?rev=10789&view=rev Author: abarth93 Date: 2012-07-31 11:34:27 +0000 (Tue, 31 Jul 2012) Log Message: ----------- bug fix: elements of struct arrays are found by strcmp instead of strmatch Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m trunk/octave-forge/extra/ncArray/inst/ncCatArray.m trunk/octave-forge/extra/ncArray/inst/nccoord.m Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m 2012-07-31 08:46:57 UTC (rev 10788) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m 2012-07-31 11:34:27 UTC (rev 10789) @@ -52,7 +52,7 @@ elseif strcmp(idx.type,'.') % load attribute name = idx.subs; - index = strmatch(name,{self.vinfo.Attributes(:).Name}); + index = find(strcmp(name,{self.vinfo.Attributes(:).Name})); if isempty(index) error('variable %s has no attribute called %s',self.varname,name); Modified: trunk/octave-forge/extra/ncArray/inst/ncCatArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-07-31 08:46:57 UTC (rev 10788) +++ trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-07-31 11:34:27 UTC (rev 10789) @@ -77,7 +77,7 @@ for i=1:length(coord) - % coordinates do also depend on the dimension only which we concatenate + % coordinates do also depend on the dimension on which we concatenate coord(i).val = arr(dim,filenames,coord(i).name); if dim > length(coord(i).dims) coord(i).dims{dim} = catdimname; Modified: trunk/octave-forge/extra/ncArray/inst/nccoord.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-31 08:46:57 UTC (rev 10788) +++ trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-31 11:34:27 UTC (rev 10789) @@ -24,19 +24,21 @@ coord = struct('name',{},'dims',{}); % check the coordinate attribute -index = strmatch('coordinates',{vinfo.Attributes(:).Name}); -if ~isempty(index) +if ~isempty(vinfo.Attributes) + index = find(strcmp('coordinates',{vinfo.Attributes(:).Name})); + if ~isempty(index) tmp = strsplit(vinfo.Attributes(index).Value,' '); for i=1:length(tmp) coord = addcoord(coord,tmp{i},finfo); end + end end % check for coordinate dimensions for i=1:length(dims) % check if variable with the same name than the dimension exist - index = strmatch(dims{i},{finfo.Variables(:).Name}); + index = find(strcmp(dims{i},{finfo.Variables(:).Name})); if ~isempty(index) coord = addcoord(coord,dims{i},finfo); end @@ -48,14 +50,17 @@ function coord = addcoord(coord,name,finfo) % check if coordinate is aleady in the list -if isempty(strmatch(name,{coord(:).name})) +if isempty(find(strcmp(name,{coord(:).name}))) % check if name is variable - index = strmatch(name,{finfo.Variables(:).Name}); + index = find(strcmp(name,{finfo.Variables(:).Name})); if ~isempty(index) c.name = name; - c.dims = {finfo.Variables(index).Dimensions(:).Name}; - + d = finfo.Variables(index).Dimensions; + c.dims = {d(:).Name}; + % does not work in octave + %c.dims = {finfo.Variables(index).Dimensions(:).Name}; + %keyboard coord(end+1) = c; end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |