Assemble Global Stiffness Matrix

9 次查看(过去 30 天)
%% INPUTs:
A = 2300; % Cross-Sectional Area of member (in mm^2)
E = 2*10^5; % Elastic Modulus (in N/mm/mm)
L(:,1) = 4000; % Length of Member-1 (in mm)
L(:,2) = 6000; % Length of Member-2 (in mm)
t(:,1) = 0; % Theta-1
t(:,2) = 90; % Theta-2
t(:,3) = rad2deg(atan(L(:,2)/L(:,1))); % Theta-3
N = numel(t)
%% OUTPUTs:
L(:,3) = sqrt(L(:,1)^2 + L(:,2)^2); %Length of Member-3 (in mm)
for i = 1:N
k{i} = [A*E/L(:,i) 0 -A*E/L(:,i) 0;0 0 0 0;-A*E/L(:,i) 0 A*E/L(:,i) 0;0 0 0 0];
C{1,i} = [cosd(t(:,i)) -sind(t(:,i)) 0 0;sind(t(:,i)) cosd(t(:,i)) 0 0;0 0 cosd(t(:,i)) -sind(t(:,i));0 0 sind(t(:,i)) cosd(t(:,i))];
D{1,i} = transpose(C{1,i});
K{1,i} = C{1,i}*k{1,i}*D{1,i};
end
From this code, I'm able to get (4*4) size [K] matrices such that K{1,1} = K1; K{1,2} = K2 & K{1,3} = K3. Now, I want them to assemble in such a way that it ends up into a global matrices of K (6*6) matrix.
K{1,1} - U1 V1 U2 V2
K{1,2} - U2 V2 U3 V3
K{1,3} - U1 V1 U3 V3
Need global assembly matrix such that: [K] based on U1 V1 U2 V2 U3 V3. For more clarification, I'm attaching image.

采纳的回答

Voss
Voss 2024-3-1
%% INPUTs:
A = 2300; % Cross-Sectional Area of member (in mm^2)
E = 2*10^5; % Elastic Modulus (in N/mm/mm)
L(:,1) = 4000; % Length of Member-1 (in mm)
L(:,2) = 6000; % Length of Member-2 (in mm)
t(:,1) = 0; % Theta-1
t(:,2) = 90; % Theta-2
t(:,3) = rad2deg(atan(L(:,2)/L(:,1))); % Theta-3
N = numel(t)
N = 3
%% OUTPUTs:
L(:,3) = sqrt(L(:,1)^2 + L(:,2)^2); %Length of Member-3 (in mm)
for i = 1:N
k{i} = [A*E/L(:,i) 0 -A*E/L(:,i) 0;0 0 0 0;-A*E/L(:,i) 0 A*E/L(:,i) 0;0 0 0 0];
C{1,i} = [cosd(t(:,i)) -sind(t(:,i)) 0 0;sind(t(:,i)) cosd(t(:,i)) 0 0;0 0 cosd(t(:,i)) -sind(t(:,i));0 0 sind(t(:,i)) cosd(t(:,i))];
D{1,i} = transpose(C{1,i});
K{1,i} = C{1,i}*k{1,i}*D{1,i};
end
%% assemble global K:
idx = {1:4, 3:6, [1 2 5 6]};
K_global = zeros(6);
for ii = 1:numel(idx)
K_global(idx{ii},idx{ii}) = K_global(idx{ii},idx{ii})+K{ii};
end
%% display global K:
format short g
disp(K_global)
1.3463e+05 29442 -1.15e+05 0 -19628 -29442 29442 44163 0 0 -29442 -44163 -1.15e+05 0 1.15e+05 0 0 0 0 0 0 76667 0 -76667 -19628 -29442 0 0 19628 29442 -29442 -44163 0 -76667 29442 1.2083e+05
  7 个评论
Torsten
Torsten 2024-3-1
A(1,1) = double(soln.f1)
A(2,1) = double(soln.f2)
and so on.

请先登录,再进行评论。

更多回答(1 个)

Aquatris
Aquatris 2024-3-1
I think this is what you are looking for. You can extend the logic in a better way if you have more than 3 nodes.
% create random 4x4 matrices with different magnitude to see the results
% clearly
K1 = rand(4);
K2 = rand(4)+10;
K3 = rand(4)+100;
K = zeros(6); % initialize global K
idx_1 = [1 2]; % column and row number corresponding to U1 V1
idx_2 = [3 4]; % column and row number corresponding to U2 V2
idx_3 = [5 6]; % column and row number corresponding to U3 V3
% Assemble the K matrix
K([idx_1 idx_2],[idx_1 idx_2]) = K([idx_1 idx_2],[idx_1 idx_2]) + K1; % U1 V1 U2 V2 part
K([idx_2 idx_3],[idx_2 idx_3]) = K([idx_2 idx_3],[idx_2 idx_3]) + K2; % U2 V2 U3 V3 part
K([idx_1 idx_3],[idx_1 idx_3]) = K([idx_1 idx_3],[idx_1 idx_3]) + K3; % U1 V1 U3 V3 part
disp(K)
100.5298 100.5934 0.4374 0.6968 100.4007 100.8383 101.4022 101.0052 0.0152 0.0705 100.2386 100.2537 0.5424 0.3041 11.4423 11.5954 10.3730 10.4325 0.3082 0.5288 11.3503 11.0871 10.8858 10.6074 100.9454 100.6493 10.0834 10.2776 111.6072 111.5421 100.3796 100.1210 10.0190 10.5509 111.3972 111.4889

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by