Create a matrix from some given matrices

1 次查看(过去 30 天)
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.

回答(2 个)

David Hill
David Hill 2019-9-23
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 2019-9-23
>> 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

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by