Clear Filters
Clear Filters

Toeplitz Matrix Generation from 2 MATRICES

2 views (last 30 days)
Hello Everyone,
I know we can define a row and column vector then use the toeplitz function to generate a toeplitz matrix, but how can I do that when I have two matrices instead of vectors?
Suppose I have matrices A and B, and I want to generate a toeplitz matrix such that;
T = [B 0 0 ... 0;
A*B B 0 ... 0;
A^2*B A*B B ... 0;
. . . ... .
. . . ... .
A^(n-1)*B A^(n-2)*B . ... B];
size(A) is KxK
size(B) is KxM
  2 Comments
Stephen23
Stephen23 on 18 May 2020
@Saleh Msaddi: just to be sure: each of those * is an actual matrix multiply?
So the output T will have size (n+1)*K x (n+1)*M ?
Saleh Msaddi
Saleh Msaddi on 18 May 2020
Yeah that's true, actually I did a small edit so that the size of the output is (n*K) x (n*M)

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 18 May 2020
Edited: Stephen23 on 18 May 2020
>> A = rand(3,3);
>> B = rand(3,5);
>> N = 4;
>> F = @(n)(A^n)*B;
>> C = arrayfun(F,0:N,'uni',0);
>> C = [{zeros(size(B))},C];
>> X = 1+tril(1+toeplitz(0:N));
>> M = cell2mat(C(X))
M =
0.69956 0.86686 0.20666 0.46757 0.94893 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
0.46328 0.36229 0.56426 0.85822 0.71207 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
0.77021 0.83655 0.31248 0.91479 0.48724 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
1.04535 1.08015 0.66586 1.30393 1.19787 0.69956 0.86686 0.20666 0.46757 0.94893 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
1.19151 1.33153 0.52492 1.24584 1.20115 0.46328 0.36229 0.56426 0.85822 0.71207 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
1.13782 1.29286 0.44387 1.14332 1.08196 0.77021 0.83655 0.31248 0.91479 0.48724 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
1.92239 2.11932 0.91061 2.08183 1.97011 1.04535 1.08015 0.66586 1.30393 1.19787 0.69956 0.86686 0.20666 0.46757 0.94893 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
1.89463 2.07432 0.92888 2.08761 1.95665 1.19151 1.33153 0.52492 1.24584 1.20115 0.46328 0.36229 0.56426 0.85822 0.71207 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
1.73168 1.89633 0.84706 1.90766 1.78390 1.13782 1.29286 0.44387 1.14332 1.08196 0.77021 0.83655 0.31248 0.91479 0.48724 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
3.13506 3.43921 1.52166 3.43777 3.22857 1.92239 2.11932 0.91061 2.08183 1.97011 1.04535 1.08015 0.66586 1.30393 1.19787 0.69956 0.86686 0.20666 0.46757 0.94893 0.00000 0.00000 0.00000 0.00000 0.00000
3.12822 3.43513 1.51057 3.42191 3.21683 1.89463 2.07432 0.92888 2.08761 1.95665 1.19151 1.33153 0.52492 1.24584 1.20115 0.46328 0.36229 0.56426 0.85822 0.71207 0.00000 0.00000 0.00000 0.00000 0.00000
2.85612 3.13678 1.37809 3.12326 2.93605 1.73168 1.89633 0.84706 1.90766 1.78390 1.13782 1.29286 0.44387 1.14332 1.08196 0.77021 0.83655 0.31248 0.91479 0.48724 0.00000 0.00000 0.00000 0.00000 0.00000
5.15716 5.66180 2.49328 5.64461 5.30487 3.13506 3.43921 1.52166 3.43777 3.22857 1.92239 2.11932 0.91061 2.08183 1.97011 1.04535 1.08015 0.66586 1.30393 1.19787 0.69956 0.86686 0.20666 0.46757 0.94893
5.13621 5.63814 2.48462 5.62330 5.28412 3.12822 3.43513 1.51057 3.42191 3.21683 1.89463 2.07432 0.92888 2.08761 1.95665 1.19151 1.33153 0.52492 1.24584 1.20115 0.46328 0.36229 0.56426 0.85822 0.71207
4.68804 5.14614 2.26789 5.13272 4.82305 2.85612 3.13678 1.37809 3.12326 2.93605 1.73168 1.89633 0.84706 1.90766 1.78390 1.13782 1.29286 0.44387 1.14332 1.08196 0.77021 0.83655 0.31248 0.91479 0.48724
And checking:
>> B % equal to main diagonal (e.g. top left corner and bottom right corner):
B =
0.69956 0.86686 0.20666 0.46757 0.94893
0.46328 0.36229 0.56426 0.85822 0.71207
0.77021 0.83655 0.31248 0.91479 0.48724
>> A^N*B % equal to bottom left corner
ans =
5.1572 5.6618 2.4933 5.6446 5.3049
5.1362 5.6381 2.4846 5.6233 5.2841
4.6880 5.1461 2.2679 5.1327 4.8230
  4 Comments
Saleh Msaddi
Saleh Msaddi on 18 May 2020
Alright. Just to make sure, in the code you provided, the size of M is (n*K) x (n*M) and size of R is (n*k) x (r*M), right?
Stephen23
Stephen23 on 18 May 2020
Edited: Stephen23 on 18 May 2020
"...the size of M is (n*K) x (n*M) and size of R is (n*k) x (r*M), right?"
As far as I can tell those are the output sizes.
But you don't need to ask me: simply try the code on a few random input matrices of different sizes, with a few r and N values, and you can check the output sizes for yourself. Or you can reverse engineer the code and confirm that it does what you want (take it apart, figure out how it works, check the output of each line).

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!