the global stiffness of two 4x4 matrices of truss

조회 수: 2 (최근 30일)
Mohammad
Mohammad 2023년 9월 21일
댓글: Mohammad 2023년 9월 22일
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

채택된 답변

Fifteen12
Fifteen12 2023년 9월 21일
편집: Fifteen12 2023년 9월 21일
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
K = 6×6
1 1 1 1 0 0 1 1 1 1 0 0 1 1 3 3 2 2 1 1 3 3 2 2 0 0 2 2 2 2 0 0 2 2 2 2
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!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structural Analysis에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by