Mercurial > forge
changeset 12617:54713b3cb49d octave-forge
improved checking of indeces are at regular intervals
author | abarth93 |
---|---|
date | Wed, 13 May 2015 09:34:14 +0000 |
parents | a8291e04a040 |
children | 224e57d04d01 |
files | extra/ncArray/inst/@ncBaseArray/ncsub.m |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/extra/ncArray/inst/@ncBaseArray/ncsub.m Wed May 13 09:33:11 2015 +0000 +++ b/extra/ncArray/inst/@ncBaseArray/ncsub.m Wed May 13 09:34:14 2015 +0000 @@ -37,14 +37,19 @@ if length(tmp) == 1 start(i) = tmp; else + % check if indexes are at regular intervals test = tmp(1):tmp(2)-tmp(1):tmp(end); - + if size(tmp,2) == 1 + % tmp is a row vector, make test also a row vector + test = test'; + end + if all(tmp == test) start(i) = tmp(1); stride(i) = tmp(2)-tmp(1); count(i) = (tmp(end)-tmp(1))/stride(i) +1; else - error('indeces'); + error('indeces not at regular intervals'); end end end