the global stiffness of two 4x4 matrices of truss
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammad
am 21 Sep. 2023
Kommentiert: Mohammad
am 22 Sep. 2023
How do I make a code to assemble these two 4x4 matrices to get the 6x6 global stiffness matric as shown?
clear all;
clc;
K1=[1 1 -1 -1;
1 1 -1 -1;
-1 -1 1 1;
-1 -1 1 1];
K2=[1 -1 -1 1;
-1 1 1 -1;
-1 1 1 -1;
1 -1 -1 1];
%here are the two matrices
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1489372/image.png)
0 Kommentare
Akzeptierte Antwort
Fifteen12
am 21 Sep. 2023
Bearbeitet: Fifteen12
am 21 Sep. 2023
To add the matrices together, just arrange them by indices.
% Dummy values for k1 and k2
k1 = ones(4,4);
k2 = ones(4,4) * 2;
% Calculate stiffness matrix
K = zeros(6,6);
K(1:4, 1:4) = k1;
K(3:6, 3:6) = K(3:6,3:6) + k2
You can make this more robust by using variables instead of hard coding the indices, but this minimal example shows the concept. Good luck with your finite elements!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Statics and Dynamics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!