필터 지우기
필터 지우기

Sum over a dimension

조회 수: 2 (최근 30일)
Mike Nguyen
Mike Nguyen 2017년 12월 18일
답변: Roger Stafford 2017년 12월 18일
Suppose I have a V-by-K A matrix, a K-by-K B matrix, and K-by-N C matrix. How should I sum over k from 1 to K specified summation(k=1..K)of product (A_vk*B_kk*C_kn).

답변 (1개)

Roger Stafford
Roger Stafford 2017년 12월 18일
Bd = diag(B);
D = zeros(V,N);
for iv = 1:V
for in = 1:N
D(iv,in) = sum((A(iv,1:K).').*Bd(1:K).*C(1:K,in));
end
end

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by