Asked by Jakov Simjanoski
on 8 Jul 2018

Sorry I cannot formulate my question in a clearer way. Here is what I want to do: A = [ a, b; c, d ] and B = [ i, j; k, l ] I want to get: C = [ (a+i), (b+j); (a+k), (b+l); (c+i), (d+j); (c+k), (d+l) ]. Thank you in advance.

Answer by Anton Semechko
on 8 Jul 2018

Accepted Answer

Do

kron([a b;c d],[1;1]) + kron([1;1],[i j;k l])

Here is an example using symbolic expressions

syms a b c d i j k l

kron([a b;c d],[1;1]) + kron([1;1],[i j;k l])

ans =

[ a + i, b + j]

[ a + k, b + l]

[ c + i, d + j]

[ c + k, d + l]

Jakov Simjanoski
on 8 Jul 2018

Anton Semechko
on 8 Jul 2018

Suppose A and B are your two matrices (where A and B are the equivalents of [a b; c d] and [i j;k l], respectively). Do:

N=size(A,1);

C=kron(A,ones(N,1)) + kron(ones(N,1),B);

Jakov Simjanoski
on 8 Jul 2018

Thank you again!

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.