Problem 498. Find the Kronecker Tensor Product without using KRON
The Kronecker Tensor Product is the result of multiplying all elements of a matrix with each of the elements of another matrix. The result is a large matrix bigger than either input matrix.
If X is m-by-n and Y is p-by-q, then mykron(X,Y) is m*p-by-n*q.
NOTE: n does not need to equal p as with normal matrix multiplication.
EX:
>> a=1:3;
>> b=2:4;
>> mykron(a,b)
ans = 2 3 4 4 6 8 6 9 12
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
Bruce Raine
on 16 Mar 2012
Thanks, I have made the corrections.
Freddy
on 21 Mar 2012
To address the term: "without using KRON", may you please add this (or something similar) to the test suite: % Test for kron usage fid = fopen(which(), 'r'); c = onCleanup(@()fclose(fid)); tline = fgetl(fid); while ischar(tline), if strfind(tline,'kron'), error('Don''t use kron'); end tline = fgetl(fid); end ... This should work fine after you've renamed your function and iserted it in <...>.
Bruce Raine
on 8 Apr 2012
Thanks, I applied your suggestion but with some syntactical changes. Code is fully tested now so 'kron' answers disallowed.
Solution Comments
Show commentsProblem Recent Solvers46
Suggested Problems
-
Omit columns averages from a matrix
595 Solvers
-
14631 Solvers
-
89 Solvers
-
184 Solvers
-
625 Solvers
More from this Author16
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!