You are on page 1of 2

%%% PROGRAMME 8.

2 %%%%
% ---------------------------------------------------------------
%% DECLARATION DES VARIABLES %%
k=0.120; % RAIDEURS;
numberElements=8; % NOMBRE D8ELEMENTS
numberNodes=6; % NOMBRE DE NOEUDS
elementNodes=[1 2; 2 4; 2 3; 2 3; 2 5; 3 4; 4 5; 5 6]; % CONNECTIVITE
%---------------------------------------------------------------
%% MATRICE DE RIGIDITE %%
stiffness=zeros(numberNodes,numberNodes); % INITIALISATION DE LA
% MATRICE DE RIGIDITE GLOBALE
for e=1:numberElements;
elementDof=elementNodes(e,:);
stiffness(elementDof,elementDof)=stiffness(elementDof,elementDof)+k*[1 -1;-1 1];
end
%---------------------------------------------------------------
%% CALCUL DES DEPLACEMENTS NODAUX ET DES REACTIONS
% INITIALISATION DES VECTEURS, DEPLACEMENT ET FORCE
displacements=zeros(numberNodes,1);
force=zeros(numberNodes,1);
% CONDITIONS DE CHARGEMENT
force(6)=-40;
force(4)=80;
% DEGRES DE LIBERTE CONNUS
prescribedDof=[1];
% DEGRES DE LIBERTE INCONNUS
activeDof=setdiff([1:numberNodes]',[prescribedDof]);
GDof=6; %NOMBRE DE DEGRES DE LIBERTE
displacements=solution(GDof,prescribedDof,stiffness,force);
outputDisplacementsReactions(displacements,stiffness,numberNodes,prescribedDof);

function y = SpringElementStiffness(k)
y = [k -k; -k k];

function displacements=solution(GDof,prescribedDof,stiffness,force)
activeDof=setdiff([1:GDof]',[prescribedDof]);
U=stiffness(activeDof,activeDof)\force(activeDof);
displacements=zeros(GDof,1);
displacements(activeDof)=U;

function outputDisplacementsReactions(displacements,...
stiffness,GDof,prescribedDof)
disp(displacements)
jj=1:GDof; format
[jj' displacements]
F=stiffness*displacements;
reactions=F(prescribedDof);
disp(reactions)
[prescribedDof reactions]
ans =

1.0000 0
2.0000 333.3333
3.0000 410.2564
4.0000 564.1026
5.0000 282.0513
6.0000 -51.2821

-40.0000

ans =

1.0 -40.0000

deplacements

ans =

1.0000 0
2.0000 0
3.0000 0.0769
4.0000 0.2308
5.0000 0.6154
6.0000 0.9487

reactions

ans =

1.0 -27.6923
2.0 -92.3077

You might also like