assemble global stiffness matrix

1 vue (au cours des 30 derniers jours)
Rafael Zanetti
Rafael Zanetti le 16 Avr 2020
Hello, I'd like how the easier way to assemble 2 matrices, for example, I have the following matrices:
k1 = [120 -120;-120 120]
k = zeros(5,5)
so I want to assemble this pattern:
K = [120 0 -120 0 0; 0 0 0 0 0;-120 0 120 0 0; 0 0 0 0 0; 0 0 0 0 0]
I thank you.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 16 Avr 2020
k1 = [120 -120;-120 120];
k = zeros(5,5);
k([1 3], [1 3]) = k1;
Result
k =
120 0 -120 0 0
0 0 0 0 0
-120 0 120 0 0
0 0 0 0 0
0 0 0 0 0

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by