Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Is it possible to extract the diagonal elements of a matrix into a vector?

  1. Dec 15, 2011 #1
    Is it possible to extract the diagonal elements of a matrix into a vector??

    Is it possible to extract the diagonal elements of a matrix into a vector USING ONLY MATRIX MULTIPLICATION? So no element by element multiplication, and no diag commands.

    (This will eventually be implemented in MATLAB, but I am required to only use matrix multiplication, so no commands)

    Is it even possible?

    Thanks in advance.
     
  2. jcsd
  3. Dec 15, 2011 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    Re: Is it possible to extract the diagonal elements of a matrix into a vector??

    You can do it with a sequence of matrix multiplies and adds.

    Think about how to get one diagonal element into a 1x1 matrix, and then how to "expand" the 1x1 matrix into the right place in a vector. Repeat and add...

    Possibly you combine all those steps part of a bigger matrix multiply operation (I'm speculating here) If the given matrix is order N, you might need matrices with dimensions of N2 or even N3...
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Is it possible to extract the diagonal elements of a matrix into a vector?
  1. Diagonal of a Matrix (Replies: 2)

  2. Matrix elements (Replies: 12)

  3. Matrix elements (Replies: 0)

Loading...