Trying to form a large matrix from 1 small matrix
Afficher commentaires plus anciens
Here is the code:
clear all
clc
syms s x
he = 1/22
k_e = [12/(he^3) 12/(he^3) 6/(he^2) 6/(he^2);
12/(he^3) 12/(he^3) -6/(he^2) -6/(he^2);
6/(he^2) -6/(he^2) 4/(he^2) 2/(he^2);
6/(he^2) -6/(he^2) 2/(he^2) 4/(he^2)];
k_g = zeros(46)
for r = 1:23
for c = 1:23
if c = 21
continue
end
if r = 21
continue
end
k_g(r+2,c+2) = k_e;
end
end
k_g
The aim is to insert k_e in k_g after 2 rows and 2 columns and sum the merging values
By "sum mergin vaues", I mean that first time k_e is in k_g, it takes 1,1 to 4,4.
The next time, k_e is inserted starting from 3,3 position and the values at 3,3 3,4 4,3 4,4 are summed with the previous k_e in k_g.
Just as an example, a 2x2 (k_e) which looks like this:
a = [A B C;
D E F;
G H I];
Which added again and again in to b should look like this:
b = [A B C 0 0 0 0;
D E F 0 0 0 0;
G H I+A B C 0 0;
0 0 D E F 0 0;
0 0 G H I+A B C;
0 0 0 0 D E F;
0 0 0 0 G H I];
I hope it clarifies the problem.
Only this time, the a is a 4x4 and b is 46x46 and a is inserted at every (n+2)th row and (n+2)th column
Thanks
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!