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



Matrix index question
Posted:
Jul 8, 1996 10:47 AM


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(c1) ] + v )
but is there any more obvious or straightforward way to do this?
Mark Broadie mbroadie@research.gsb.columbia.edu



