How to generate an nxn matrix using n number of 2x2 matrices?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Monique Embury
el 22 de En. de 2019
Comentada: Monique Embury
el 29 de En. de 2019
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 comentarios
Guillaume
el 23 de En. de 2019
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.
Respuesta aceptada
Guillaume
el 24 de En. de 2019
"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 comentarios
Guillaume
el 29 de En. de 2019
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.
Más respuestas (1)
jahanzaib ahmad
el 22 de En. de 2019
Editada: Guillaume
el 23 de En. de 2019
u just want to add stiffness matrix of each element to get n x n stiffness matrix
1 comentario
jahanzaib ahmad
el 22 de En. de 2019
Editada: jahanzaib ahmad
el 22 de En. de 2019
else share code and explain bit more about problem please
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!