maxwell <refetalony@gmail.com> wrote in message <245609f8-a2a6-46a0-a385-1ee9566cfd46@googlegroups.com>... > hi > how to write the follow loop in matrix term? > > for i = 1:size(A,1) > for j = 1:size(A,2) > B(i,j) = A(i,i) * A(j,j); > end > end

B=a'*a where a=[A_11 A_22 A_33 ... A_nn], the diagonal of the square matrix A.