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: create a vector of values from a vector of indices
Replies: 1   Last Post: Jan 31, 2013 8:02 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Bruno Luong

Posts: 9,240
Registered: 7/26/08
Re: create a vector of values from a vector of indices
Posted: Jan 31, 2013 8:02 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Martin Claverie" <mcl@umd.edu> wrote in message <kedphf$ivr$1@newscl01ah.mathworks.com>...
> B = [3 4 1 8 5 6 3 1]';
> % I want to create a vector C without using this loop:
> C = zeros(size(B));
> for i=1:length(C)
> C(i) = A(B(i));
> end

C = A(B)

% Bruno

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

[Privacy Policy] [Terms of Use]

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