Create a matrix from some given matrices

I have this matrix to implement. Where user would define the value of dimensions ( p and N).
Annotatnjhion.png
what would be the most efficient way to doing this in matlab.

Réponses (2)

David Hill
David Hill le 23 Sep 2019
As long as the size of matrices A,B,and C are the same, creating new matrix as listed above is as simple as the following.
newMatrix = [A,B,zeros(size(A));C,A,B;zeros(size(A)),C,A];
Stephen23
Stephen23 le 23 Sep 2019
>> p = 2;
>> N = 3;
>> A = randi(9,p,p)
A =
6 7
2 1
>> B = randi(9,p,p)
B =
3 1
1 8
>> C = randi(9,p,p)
C =
7 9
3 1
>> D = {zeros(p,p),C,A,B};
>> V = ones(1,N-2);
>> X = toeplitz([3,2,V],[3,4,V]);
>> M = cell2mat(D(X))
M =
6 7 3 1 0 0
2 1 1 8 0 0
7 9 6 7 3 1
3 1 2 1 1 8
0 0 7 9 6 7
0 0 3 1 2 1

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by