Hi, my loop function is not working and giving me index error in my member stiffens matrix. any idea what is the issue? thank you
Show older comments
%define coordinates of each nodes%
Coord_nodes = [0 0; 10 0; 10 10; 0 10];
% define connection of each element%
Connect_elements = [1 2; 1 3; 1 4; 4 3; 4 2; 2 3];
%define degree of Freedom of each nodes
Deg_free=[1 2; 6 5; 7 8; 3 4];
% define number of reactions at supports
Nr= 3;
%define number of members
Nm= 6;
%define number of nodes
Nn= 4;
%define EA
EA= 1;
%define Lenght of each member
L=zeros(Nm,1);
L= [10; 14.14 ;10 ;10 ; 14.14 ;10]
% creation of ID Array
ID = zeros(Nm,4);
for k = 1:Nm
i = Connect_elements(k,1);
j = Connect_elements(k,2);
ID(k,1:2)=Deg_free(i,1:2);
ID(k,3:4)=Deg_free(j,1:2);
end
% assemble Global Stiffness matrix
Kg=zeros(8,8);
for k = 1:Nm
i = Connect_elements(k,1);
j = Connect_elements(k,2);
Lamda_x= (Coord_nodes(j,1)- Coord_nodes(i,1))/L(k)
Lamda_y= (Coord_nodes(j,2)- Coord_nodes(i,2))/L(k)
end
%member Stiffness matrix
for k = 1:Nm
k11(k)= (Lamda_x(k)^2/L(k));
k12(k)= (Lamda_x(k)*Lamda_y(k))/L(k);
k13(k)= -k11(k);
k14(k)= (-Lamda_x(k)*Lamda_y(k))/L(k);
k21(k)= k12(k);
k22(k)= (Lamda_y(k))^2/L(k);
k23(k)= -k12(k);
k24(k)= -k22(k);
k31(k)= -k11(k);
k32(k)= k23(k);
k33(k)= k11(k);
k34(k)= k12(k);
k41(k)= k14(k);
k42(k)= k24(k);
k43(k)= k12(k);
k44(k)= k22(k);
k_elem(:,:,k)= [k11(k) k21(k) k31(k) k41(k);
k12(k) k22(k) k32(k) k42(k);
k13(k) k23(k) k33(k) k43(k);
k14(k) k24(k) k34(k) k44(k)]
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!