Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



A more matlab like way?
Posted:
Feb 28, 2013 10:16 AM


I have 2 vectors of counts. One is a subset of the other. both lists are sorted ascending. I'd like to expand the subset list to include any count in the big list that's within 1 of a count in the subset. For example if
large = [1 2 3 4 5 9 11 15 16 21 22 27 28 31 33]; subset = [2 4 11 21 27];
then I'd like
outlist = [1 2 3 3 4 5 11 21 22 27 28];
One way would be to (pseudo code, untested)
outlist = []; for ix = 1:numel(subset) low = subset(ix)1; high = subset(ix)+1; temp = find(low<=large & large<=high); outlist = [outlist large(temp)]; end
But it doesn't seem to be "the matlab way".
Is there a better way?
Bruce



