a simple vector to a matrix
Show older comments
Hello everyone,
I am trying to write a code that convert a vector like the following for example:
X=[1 2 3];
to a matrix like the following:
Z=[1 0 0 2 0 0 3 0 0;...
0 1 0 0 2 0 0 3 0;...
0 0 1 0 0 2 0 0 3];
Any ideas?
Thanks very much.
Answers (2)
X=[1 2 3];
I = eye(3);
kron(X, I)
kron(I, X)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!