Tensor product 2 matrices - kronecker product

A question regarding the tensor product of 2 matrices, in combination with the Kronecker product.
I have 2 matrices: Qz and Qx.
Qx is Ns* Nx;
Qz is Ns * Nz.
Ns is the total states, consisting of all possible combinations of x and z (so Ns = Nx * Nz).
Lets say Ns = 14400; Nx = 3600; Nz = 4.
Then, I would like to multiply them using Tensor products, i.e. Q = Qz * Qx.
Is there any way to do this and to avoid to have a loop and apply the kron-function Ns times, to fill the matrix?

3 Comments

Please provide a small example showing inputs and desired output so we are sure what you want.
This is what I want, code:
Nstates = 6;
Qz = ones(Nstates, 2)*0.5;
Qx = linspace(1,Nstates*3, Nstates*3);
Qx = reshape(Qx, Nstates, 3);
Q = zeros(Nstates, Nstates);
for si = 1: Nstates
Q(si,:)= kron(Qz(si,:), Qx(si,:));
end
So the input is:
Qz =
0.5000 0.5000
0.5000 0.5000
0.5000 0.5000
0.5000 0.5000
0.5000 0.5000
0.5000 0.5000
Qx =
1 7 13
2 8 14
3 9 15
4 10 16
5 11 17
6 12 18
And then I do a Kronecker product of Qz times Qx, for each row of Qx.
So then the total matrix Q will be Ns*Ns, while Qz is Ns*Nz and Qx is Ns*Nx.
Q =
0.5000 3.5000 6.5000 0.5000 3.5000 6.5000
1.0000 4.0000 7.0000 1.0000 4.0000 7.0000
1.5000 4.5000 7.5000 1.5000 4.5000 7.5000
2.0000 5.0000 8.0000 2.0000 5.0000 8.0000
2.5000 5.5000 8.5000 2.5000 5.5000 8.5000
3.0000 6.0000 9.0000 3.0000 6.0000 9.0000
Do you know if there is a way to avoid the loop?

Sign in to comment.

 Accepted Answer

More Answers (0)

Categories

Asked:

on 26 Jun 2019

Answered:

on 29 Jun 2019

Community Treasure Hunt

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

Start Hunting!