Hello,

I have a matrix A of dimension k x (d-1) and a matrix B of dimension m x (d-1).

I wish to compute an expression C = Sum from i=1 to i=d-1 of ( A(j,i)* (column number i of B) )

C will be a vector of length m, on which my script will then do other operations.

My problem is with the j index in A(j,i). I first considered a simple "for" expression, with "for j=1:k", but it does not match what i would like to obtain. In fact, I don't want each A(j,i) in each term of the sum to be with the same j. For example, in the first run, C will be obtained by summing : A(1,1)*column1ofB + A(1,2)*column2ofB + … + A(1,d-1)*column(d-1)ofB. With the simple "for" expression that I had considered, the second run would be : A(2,1)*column1ofB + A(2,2)*column2ofB + … + A(2,d-1)*column(d-1)ofB. Between those two runs, I would like to compute also the possibilities like the sum containing A(1,1), A(2,2), A(1,3)… and A(1,d-1) as well as for example the sum containing A(1,1), A(1,2), A(2,3)…and A(1,d-1). I would like to have all "permutations".

How could I implement that? Thank you very much!

## Best Answer