Sum of matrices obtained as sum of vector products

조회 수: 2 (최근 30일)
Ana
Ana 2011년 9월 29일
Hello, I have a set of column vectors, organized in a matrix of size (number of vectors)x(length of vectors).
I need to construct a matrix as the sum of (number of vectors) matrices constructed from each vector as the product of the column vector times the vector transposed. DO you know any easy form to do this without a loop (which is very time consuming)? What I really need is the inverse of this matrix, but I guess there is no easy way to obtain it easyly.
Thank you very much in advance!
Ana

채택된 답변

Honglei Chen
Honglei Chen 2011년 9월 29일
Hi Ana,
Let's say your matrix is X. If I understand correctly, each row of X is a vector you want and that vector suppose to be a column vector. If that is true I believe you are talking about forming sample covariance matrix. In your case, you can simply do it by
R = X'*X;
This being said, it is rare that you want to really invert R. In most cases, what you want is R^(-1)v where v being a vector. Hence, instead of using
inv(R)*v
you should do
R\v
HTH
  댓글 수: 1
Ana
Ana 2011년 9월 30일
Thank you very much! I knew there should be an easy way of doing this, but I couldn't realize how!
Yes, what I really need R^(-1)v, I posed the question in that way just in case it was simple to obtain the inverse of that matrix in an analytic way or something.
Thanks again!
Ana

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by