Borrar filtros
Borrar filtros

Sum over a dimension

2 visualizaciones (últimos 30 días)
Mike Nguyen
Mike Nguyen el 18 de Dic. de 2017
Respondida: Roger Stafford el 18 de Dic. de 2017
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).

Respuestas (1)

Roger Stafford
Roger Stafford el 18 de Dic. de 2017
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

Categorías

Más información sobre Sparse Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by