필터 지우기
필터 지우기

How to generate an nxn matrix using n number of 2x2 matrices?

조회 수: 3 (최근 30일)
Monique Embury
Monique Embury 2019년 1월 22일
댓글: Monique Embury 2019년 1월 29일
Hi,
I am having trouble generating a code in the exisiting loop to create a global stiffness matrix from each element stiffness matrix. I am trying to program matlab to do something similar to this.
I have written the code and loop to generate the connectivity matrix and each element stiffness matrix. I am hoping to use the same loop to generate the global stiffness matrix.
e = %connectivity table
1 1 2
2 2 3
3 3 4
4 4 5
5 5 6
6 6 7
%element stiffness matricies
ke(:,:,1) =
1.5708 -1.5708
-1.5708 1.5708
ke(:,:,2) =
0.8836 -0.8836
-0.8836 0.8836
ke(:,:,3) =
0.6981 -0.6981
-0.6981 0.6981
ke(:,:,4) =
0.6136 -0.6136
-0.6136 0.6136
ke(:,:,5) =
0.5655 -0.5655
-0.5655 0.5655
ke(:,:,6) =
0.5345 -0.5345
-0.5345 0.5345
>>
Can anyone help me?
Thank you!
%Element connectivity Table
n=6; %creates 6 elements
e=[]; %creates empty connectivity matrix
k=[1 -1;-1 1]; %standard format of K
ke=[]; %creates empty element stiffness matrix
Ae=[]; %creates empty element area amatrix
ks=zeros(n,n);
E=1;
L=2;
R1=1;
R2=0.5;
i=1;
for m=1:n; %goes through each element
i=i;
j=i+1;
x=L/m;%thickness of each slice of the beam
A1=pi()/L^2*(R2*L+(R1-R2)*x)^2;%area of each slice of the beam
Ae(:,m)=[A1];%stores each area in a matrix
e(m,:)= [m i j];%stores results in matrix
ke(:,:,m)=E*Ae(:,m)/L*k; %stores each element stiffness matrix
end
  댓글 수: 4
Guillaume
Guillaume 2019년 1월 23일
I'm also not sure what the question is. Furthermore, as far as I can tell you explain how to form a matrix for two springs in series but not when they're in parallel. I don't know anything about stiffness matrices, but I would assume the result is not the same for parallel springs.
I can see several possible question with what you have described. Given a connectivity table, the first task would probably be to find which springs are in parallel and which are in series. Once that is done you would then have to assemble the matrices according to the relevant formula. It's not clear which part of this you need help with.
Monique Embury
Monique Embury 2019년 1월 23일
In my problem, the springs are in series.
The image posted is an example of what I am trying to do. In the example, 2 2x2 matrices are combined to make a 3x3 matrix.
I am trying to combine 6 2x2 matrices to create a 6x6 matrix in a similar fashion. I am not sure how to program this. That is what I am seeking help on.

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

채택된 답변

Guillaume
Guillaume 2019년 1월 24일
"I am trying to combine 6 2x2 matrices to create a 6x6 matrix in a similar fashion"
According to your algorithm the stiffness matrix will be 7x7 not 6x6. It is trivial to achieve
% inputs:
% ke: a 2x2xN matrix
stiffness_matrix = zeros(size(ke, 3) + 1); %create a (N+1)x(N+1) matrix of 0s
for idx = 1:size(ke, 3)
stiffness_matrix(idx:idx+1, idx:idx+1) = stiffness_matrix(idx:idx+1, idx:idx+1) + ke(:, :, idx);
end
  댓글 수: 10
Guillaume
Guillaume 2019년 1월 29일
The construction of the stiffness matrix can only happen after KE has been fully constructed, not during the construction, so move that code after the c loop.
Monique Embury
Monique Embury 2019년 1월 29일
You are amazing and thank you so very much for your help!

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

추가 답변 (1개)

jahanzaib ahmad
jahanzaib ahmad 2019년 1월 22일
편집: Guillaume 2019년 1월 23일
u just want to add stiffness matrix of each element to get n x n stiffness matrix
  댓글 수: 1
jahanzaib ahmad
jahanzaib ahmad 2019년 1월 22일
편집: jahanzaib ahmad 2019년 1월 22일
else share code and explain bit more about problem please

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by