# Everything being the same, then why does matrix C give different values in the two codes?

2 views (last 30 days)
Sadiq Akbar on 16 Oct 2021
Commented: Sadiq Akbar on 19 Oct 2021
All the values are the same in both the codes, then why does matrix C give different values in both the codes?
code1:
u=[30 50 110];
M=10;
N=4;
K=3;
d=0.5;
fn=@(u,k) exp(1j*2*pi*d*(0:k-1).' * sind(u));
A=fn(u,M);
B=fn(u,N);
C=kron(B,A);
code2
u=[30 50 110];
M=10;
N=4;
K=3;
d=0.5;
C = STM(u,M,N,d);
function C = STM(u,M,N,d)
A=exp(1j*2*pi*d*(0:M-1).'*sind(u));
B=exp(1j*2*pi*d*(0:N-1).'*sind(u));
C = zeros(size(A, 1)*size(B, 1), length(u));
for idxK = 1 : 1 : length(u)
C(:, idxK) = kron(B(:, idxK), A(:, idxK));
end
end

Cris LaPierre on 16 Oct 2021
Because they are not the same?
Your output should be [size(A, 1)*size(B, 1), size(A, 2)*size(B, 2)]
See the More About > Kroeneker Tensor Product for what kron is calculating.
Sadiq Akbar on 19 Oct 2021
Thank you dear Cris LaPierre for your response. No you didn't take my point. I was saying that I want to make the response of the 1st code like that of 2nd. You tried but that is not according to my question. I wanted to make the response of 1st code like that of 2nd and I did that myself with several trial and errors. Thank you once again