Create a matrix from some given matrices
Mostrar comentarios más antiguos
I have this matrix to implement. Where user would define the value of dimensions ( p and N).

what would be the most efficient way to doing this in matlab.
Respuestas (2)
David Hill
el 23 de Sept. de 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
el 23 de Sept. de 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
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!