Afficient way to create "sum matrix"
이전 댓글 표시
Hi,
So i would like to implement a function that get a vector as input lets :
g=[g1, g2, g3]
and return a matrix that contain a sum of pairs: so for g , the output matrix G contain 9 elements the G(i,j)=g(i)+g(j)
The problem is that g will be very large vector.
Does anyone know an efficient way to do that with sparse matrices
Thanks
채택된 답변
추가 답변 (1개)
Orr Streicher
2021년 2월 1일
0 개 추천
댓글 수: 2
You could create a function, e.g.:
g = 1:3
f = @(r,c)sum(g([r,c]));
f(1,2)
Your question mentions sparse matrices: are most of the values in g zero?
Orr Streicher
2021년 2월 1일
편집: Orr Streicher
2021년 2월 1일
카테고리
도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!