Calculate the Kronecker product K = A x B . Use nested loop operation to calculate each element of K directly and output the results with fprintf() function.
1 view (last 30 days)
Show older comments
Calculate the Kronecker product K = A x B . Use nested loop operation to calculate each element of K directly and output the results with fprintf() function.
A=round(rand(2)*11-5.5)
B=round(rand(3,4)*21-10.5)
[rA,cA] = size(A)
[rB,cB] = size(B)
K=[]
C=zeros(6,8)
for i=1:rA, n=1:6
J=[]
for j=1:cA, m=1:8
C=A(i,j)*B
J=[J,A(i,j)*B]
end
K=[K;J]
end
4 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!