%% 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일

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

Parvesh Deepan
Parvesh Deepan 2024년 3월 1일
Thanks a lot!!
Voss
Voss 2024년 3월 1일
You're welcome!
Parvesh Deepan
Parvesh Deepan 2024년 3월 1일
I've one more doubt associated with the same task:
U(1,1) = 0; % Displacement in x direction at Node-1 (mm)
U(2,1) = 0; % Displacement in y direction at Node-1 (mm)
U(3,1) = u2; % Displacement in x direction at Node-2 (mm)
U(4,1) = 0; % Displacement in y direction at Node-2 (mm)
U(5,1) = u3; % Displacement in x direction at Node-3 (mm)
U(6,1) = v3; % Displacement in y direction at Node-3 (mm)
F(1,1) = f1; % Force in x direction at Node-1 (N)
F(2,1) = f2; % Force in y direction at Node-1 (N)
F(3,1) = 0; % Force in x direction at Node-2 (N)
F(4,1) = f4; % Force in x direction at Node-2 (N)
F(5,1) = 12000; % Force in x direction at Node-3 (N)
F(6,1) = 0; % Force in y direction at Node-3 (N)
These are the values of matrix U & F both are 6*1 matrix and both contains some unknowns.
How to find unknown with the help of this equation:
[K_global]*[U] = [F] ?
Voss
Voss 2024년 3월 1일
편집: 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
%% Define U and F:
syms('f1','f2','f4','u2','u3','v3')
U = [0;0;u2;0;u3;v3];
F = [f1;f2;0;f4;12000;0];
%% Solve
soln = solve(K_global*U==F)
soln = struct with fields:
f1: -12000 f2: -758663023165439976000/42147945731413333 f4: 758663023165440048000/42147945731413333 u2: 0 u3: 109555278165705605241441878016000/113699629798874301526546156126207 v3: -9895604649984000/42147945731413333
Requires Symbolic Math Toolbox.
Parvesh Deepan
Parvesh Deepan 2024년 3월 1일
I already did this but I need to store the results in matrix form. Is this possible ?
A(1,1) = double(soln.f1)
A(2,1) = double(soln.f2)
and so on.
Parvesh Deepan
Parvesh Deepan 2024년 3월 1일
thanks

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Aquatris
Aquatris 2024년 3월 1일

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2024년 3월 1일

댓글:

2024년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by