Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: A more matlab like way?
Replies: 2   Last Post: Feb 28, 2013 4:33 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruce Bowler

Posts: 238
Registered: 12/7/04
A more matlab like way?
Posted: Feb 28, 2013 10:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.