Assembling Global Stiffness Matrix
조회 수: 157 (최근 30일)
이전 댓글 표시
I am trying to make a global stiffness matrix using a for loop from several smaller (4X4) matrices. I was able to get a loop to run for 2X2 matrices, but when I increase the number of rows and colums in my smaller matrices it no longer works. I want the loop to run when the kn matrices is rand(4). This is what I have currently:
k1=rand(2);
k2=rand(2);
k3=rand(2);
C = {k1,k2,k3};
N = numel(C);
M = zeros(1+N,1+N);
for k = 1:N
M(k:k+1,k:k+1) = M(k:k+1,k:k+1)+C{k};
end
disp(M)
댓글 수: 0
답변 (2개)
Torsten
2022년 12월 12일
This is analogous to your 2x2 code.
I don't know if it's the right way to code M.
k1=rand(4);
k2=rand(4);
k3=rand(4);
C = {k1,k2,k3};
N = numel(C);
M = zeros(3+N,3+N);
for k = 1:N
M(k:k+3,k:k+3) = M(k:k+3,k:k+3)+C{k};
end
disp(M)
댓글 수: 2
Arif Hoq
2022년 12월 13일
% creating stiff matrix
for i=1:20
stiff{i}=randi(100,4,4);
end
k1=stiff(1);
k2=stiff(2);
k3=stiff(3);
k4=stiff(4);
k5=stiff(5);
k6=stiff(6);
k7=stiff(7);
k8=stiff(8);
k9=stiff(9);
k10=stiff(10);
k11=stiff(11);
k12=stiff(12);
k13=stiff(13);
k14=stiff(14);
k15=stiff(15);
k16=stiff(16);
k17=stiff(17);
k18=stiff(18);
k19=stiff(19);
k20=stiff(20);
C = [k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,k20];
N=numel(C);
M = zeros(N,N);
for k = 1:N-3
M(k:k+3,k:k+3) = M(k:k+3,k:k+3)+C{k};
end
disp(M)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!