A=randn(10,3)+i*randn(10,3); %# Form random A and B matrices B=randn(10,3)+i*randn(10,3); diag(A*B') %# Direct calculation from definition and octave operators diagouter(A,B) %# Your routineRecall that ``''' in octave represents complex-conjugate transpose. Also, diag() takes the diagonal elements of a matrix just as in the notation from class.