assemble global stiffness matrix with varying young's modulus
Mostrar comentarios más antiguos
I am trying to assemble stifness matrix of two element beam whose elastic modus is different in each element. the elastic modulus can take any values as [1 1],[1 2],[2 1] and [2 2];
my code is
nel=2; % number of element
nnel=2; % node per element
ndof=2; % number of degree of freedom per elment
nnode=(nnel-1)*nel+1; % total number of nodes in system
sdof=nnode*ndof; % total system dofs
v=[1 2];
N=2;
p=permn(v,N);
[l m]=size(p);
kk=zeros(sdof, sdof) ;
mm=zeros(sdof,sdof);
force=zeros(sdof, 1);
index=zeros(nnel*ndof,1);
kk=zeros(sdof, sdof) ;
i=1:4;
v=[1 2];
N=2;
p=permn(v,N);
[l m]=size(p);
kk(:,:,i)=zeros(sdof, sdof,4);
for l=1:l
for iel=1:nel
edof = nnel*ndof;
start = (iel-1)*(nnel-1)*ndof;
for i=1:edof
index(i)=start+i;
end
x=p(l,iel)
k(:,:,1)=ones(4, 4) ;
k(:,:,2)=2*ones(4, 4) ;
edof = length (index);
for i=1:edof
ii=index(i) ;
for j=1:edof
jj=index(j) ;
kk(ii,jj,l)=kk(ii,jj)+k(i,j,x)
end
end
end
end
%the values of kk(::,1) is coming correct but (k:,:,2) matrix is begining
%with 2 but it should start with 1,similarlly (k:,:,3)is begining
%with 3 but it should start with 2 and same proble is with (k:,:,4)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!