Mercurial > forge
changeset 2317:49eae56677bc octave-forge
permit vectors of contiguous indexes for reading/writing netcdf variables
author | abarth93 |
---|---|
date | Mon, 05 Jun 2006 19:53:37 +0000 |
parents | 301f26107fdd |
children | c4d3e8040350 |
files | main/octcdf/example_opendap.m main/octcdf/ov-ncvar.cc |
diffstat | 2 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/main/octcdf/example_opendap.m Mon Jun 05 16:40:07 2006 +0000 +++ b/main/octcdf/example_opendap.m Mon Jun 05 19:53:37 2006 +0000 @@ -11,8 +11,8 @@ % Select the SSH for part of the North Atlantic % -i = find(-92 < lon & lon < -51); i=i(1):i(end); -j = find(23 < lat & lat < 45); j=j(1):j(end); +i = find(-92 < lon & lon < -51); +j = find(23 < lat & lat < 45); x = lon(i); y = lat(j);
--- a/main/octcdf/ov-ncvar.cc Mon Jun 05 16:40:07 2006 +0000 +++ b/main/octcdf/ov-ncvar.cc Mon Jun 05 19:53:37 2006 +0000 @@ -435,6 +435,25 @@ else if (key_idx(i).is_real_scalar()) { ranges.push_back(Range(key_idx(i).scalar_value(),key_idx(i).scalar_value())); } + else if (key_idx(i).is_matrix_type()) { + Matrix m = key_idx(i).matrix_value(); + + if (m.rows() != 1) m = m.transpose(); + + Range r = Range(m(0),m(m.numel()-1),m(1)-m(0)); + + if (r.inc() <= 0) { + error("octcdf: indexes must be increasing"); + return ranges; + } + + if (r.matrix_value() != m) { + error("octcdf: indexes must be contiguous"); + return ranges; + } + + ranges.push_back(r); + } else { error("octcdf: unknown index specification: type %s",key_idx(i).type_name().c_str()); return ranges;