Matrix Elements Manipulation Using Matlab

3 次查看(过去 30 天)
I have four matrices A, B, C and D of dimension: A=4x4; B=4x3; C=3x4; D=3x3.
A=[A11 A12 A13 A14 ;
A21 A22 A23 A24 ;
A31 A32 A33 A34 ;
A41 A42 A43 A44 ];
Elements of A matrix (like A11, A12 ...) with the indexing are shown. The other matrices also have the elements in a similar fashion (like B11, B12, ...for the B-Matrix and it applies to other remaining matrices).
Problem: I want to construct a bigger matrix of dimension 7x7 from it in the following way:
1. Place B11 in between A11 and A12; B12 in between A12 and A13 and so on.
2. Place C11 in between A11 and A21; C12 in between A12 and A22 and so on.
3. Place D11 in between C11 and C12; D12 in between C12 and C13 and so on.
Finally the matrix should look like:
H=[ A11 B11 A12 B12 A13 B13 A14;
C11 D11 C12 D12 C13 D13 C14;
A21 B21 A22 B22 A23 B23 A24;
C21 D21 C22 D22 C23 D23 C24;
A31 B31 A32 B32 A33 B33 A34;
C31 D31 C32 D32 C33 D33 C34;
A41 B41 A42 B42 A43 B43 A44];
I would be very grateful if anybody helps me in implementing the same using Matlab command.
Thanking You!

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-9-21
a=zeros(4,7);
a(:,1:2:end)=A;
a(:,2:2:end)=B;
b=zeros(3,7);
b(:,1:2:end)=C;
b(:,2:2:end)=D;
out=zeros(7);
out(1:2:end,:)=a;
out(2:2:end,:)=b

更多回答(1 个)

Lavanikaa Mariappa
Lavanikaa Mariappa 2021-7-10
x''(t)+2x'(t)+x(t)=0x''(t)+2x'(t)+x(t)=0 with x(0)=1x0=1 and x'(0)=1x'0=1,

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by