Our professor calls this the connectivity array (but not referring to Matlab)
3 views (last 30 days)
Show older comments
The goal is to combine a 3x3 matrix in a way that it becomes an 11x11 matrix. It'll be done such that the 3x3 matrix will repeat diagonally, for example if 3x3 matrix is [F G H ;
G I J;
H J F]
Then the 11x11 matrix should look like this:
[F G H 0 0 0 0 0 0 0 0;
G I J 0 0 0 0 0 0 0 0;
H J 2*F G H 0 0 0 0 0 0;
0 0 G I J 0 0 0 0 0 0;
0 0 H J 2*F G H 0 0 0 0;
0 0 0 0 G I J 0 0 0 0;
0 0 0 0 H J 2*F G H 0 0 0 0;
0 0 0 0 0 0 G I J 0 0;
0 0 0 0 0 0 H J 2*F G H;
0 0 0 0 0 0 0 0 G I J;
0 0 0 0 0 0 0 0 H J F]
notice the addition of F as a "connectivity array"
I have tried some stuff but nothing seems to work except for typing it manually and this becomes a problem if my base matrix (in this case 3x3) becomes a 10x10 or anything greater than 3x3
0 Comments
Answers (1)
Chunru
on 23 Sep 2022
% [F G H ;
% G I J;
% H J F]
% Then the 11x11 matrix should look like this:
% [F G H 0 0 0 0 0 0 0 0;
% G I J 0 0 0 0 0 0 0 0;
% H J 2F G H 0 0 0 0 0 0;
% 0 0 G I J 0 0 0 0 0 0;
% 0 0 H J 2F G H 0 0 0 0;
% 0 0 0 0 G I J 0 0 0 0;
% 0 0 0 0 H J 2F G H 0 0;
% 0 0 0 0 0 0 G I J 0 0;
% 0 0 0 0 0 0 H J 2F G H;
% 0 0 0 0 0 0 0 0 G I J;
% 0 0 0 0 0 0 0 0 H J F]
F = 1; G = 2; H = 3; I = 4; J = 5;
A = [F G H ; G I J; H J F]
B = zeros(11, 11);
for i=0:4
B(i*2+(1:3), i*2+(1:3)) = B(i*2+(1:3), i*2+(1:3)) + A;
end
B
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!