Reputation: 33
I want to create a matrix in large dimensions that the components themselves are a matrix.
Like the following example
each of the W
, V
, U
is 18*18
matrix and the other components are zero. What is the easiest way to create such a matrix in MATLAB
?
Upvotes: 3
Views: 57
Reputation: 15837
Assuming that you want a matrix that contains n x n
blocks so its dimensions will be (18 * n) x (18 * n)
:
n=10;
z=ones(n,1);
result = kron(spdiags(z,-1,n,n),V)+kron(spdiags(z,0,n,n),U)+kron(spdiags(z,1,n,n),W);
Upvotes: 4