The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to vectorize this matrix indexing
Replies: 1   Last Post: Dec 28, 2012 8:27 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jan Simon

Posts: 2,927
Registered: 10/6/08
Re: How to vectorize this matrix indexing
Posted: Dec 28, 2012 8:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear Daniel,

A = rand(10,4);
b = [2 4 1 3 2 3 1 2 4 1];
r = A(sub2ind(size(A), 1:10, b));


Kind regards, Jan

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.