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: Matrix index question
Replies: 1   Last Post: Jul 9, 1996 4:06 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Mark Nathan Broadie

Posts: 2
Registered: 12/11/04
Matrix index question
Posted: Jul 8, 1996 10:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Suppose I have a matrix A with r rows and c columns
and I have a vector v of length c, each entry is an
integer from 1 to r. How do I extract the elements

A(v(1):1), A(v(2):2), ..., A(v(c):c)

and put the results into a vector w?

My solution was
A = reshape(A, 1, r*c)
w = A( [ 0 : r : r(c-1) ] + v )

but is there any more obvious or straightforward
way to do this?

-Mark Broadie

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.