How can i implement this code?

inpfilename = uigetfile('*.txt','select the input file');
[nodes, elems, E, A, I, bcs, loads] = getframedata2D(inpfilename);
nel=size(elems, 1); nnodes=size(nodes, 1);
alldofs = 1:3*nnodes; K = zeros(3*nnodes); u = zeros(3*nnodes, 1); f = zeros(3*nnodes, 1);
dofspec = []; for ii=1:size(bcs,1) thisdof=3*(bcs(ii,1)-1)+bcs(ii,2); dofspec=[dofspec thisdof]; u(thisdof)=bcs(ii,3); end doffree=alldofs; doffree(dofspec)=[];
for ii=1:size(loads,1) f(3*(loads(ii,1)-1)+loads(ii,2))=loads(ii,3); end
for iel=1:Nel elnodes=elems(iel,1:2); nodexy=nodes(elnodes,:);
[kel]=frameelement2DBE(nodexy, E(iel), A(iel), I(iel));
eldofs=3*(elnodes(1)-1)+1:3*elnodes(1);
eldofs=[eldofs 3*(elnodes(2)-1)+1:3*elnodes(2)];
k(eldofs, eldofs)=k(eldofs,eldofs)+kel;
end
u(doffree)=k(doffree,doffree)\(f(doffree)-k(doffree,dofspec)*u(dofspec)); f(dofspec)=k(dofspec,:)*u;
disp(['Displacement and Rotations : ']); u disp(['Reactions (Forces and Moments)']); f
figure(1); hold on ; plot(nodes(:,1), nodes(:,2), 'k.') hold on; axis equal; for iel=1:Nel elnodes=elems(iel, 1:2); nodexy=nodes(elnodes,:); plot(nodexy(:,1), nodexy(:,2), 'k--') end
Magnification=20; ndive=20; xydisp=[u(1:3:end) u(2:3:end)]; nodesnew=nodes+Magnification*xydisp; plot(nodesnew(:,1), nodesnew(:,2), 'o', ... 'MarkerEdgeColor', 'k', 'MarkerFaceColor', 'r', 'MarkerSize', 10) hold on; axis eaual;
for iel=1:Nel elnodes=elems(iel, 1:2); E1=[(nodes(elnodes(2),1)-nodes(elnodes(1),1))... (nodes(elnodes(2),2)-nodes(elnodes(1),2))]; le=norm(E1); E1=E1/le; E2=[-E1(2) E1(1)];
eldofs=3*(elnodes(1)-1)+1:3*elnodes(1);
eldofs=[eldofs 3*(elnodes(2)-1)+1:3*elnodes(2)];
eldisp=u(eldofs);
Qrot=[E1; E2];
Qrot(3,3)=1;
Tmatrix=[Qrot zeros(3) ; zeros(3) Qrot];
eldispLOC=Tmatrix*eldisp;
for jj=1:ndivs+1
xi=(jj-1)/ndivs;
xdispLOC=eldispLOC(1)*(1-xi)+eldispLOC(4)*xi;
ydispLOC=eldispLOC(2)*(1-3*xi^2+2*xi^3)+eldispLOC(5)*(3*xi^2-2*xi^3)...
+eldispLOC(3)*le*(xi-2*xi^2+xi^3)+eldispLOC(6)*le*(-xi^2+xi^3);
xydisp=(Qrot([1,2],[1,2]))'*[xdispLOC ; ydispLOC];
plotpts(jj,1)=nodes(elnodes(1),1)+xi*le*E1(1)+Magnification*xydisp(1);
plotpts(jj,2)=nodes(elnodes(1),2)+xi*le*E1(1)+Magnification*xydisp(2);
end
plot(plotpts(:,1),plotpts(:,2),'k--','LineWidth',2)
end
title('Displacement');
function [kel]=FrameElemnet2DBE(nodexy, E, A, L)
El=[(nodexy(2,1)-nodexy(1,1))... (nodexy(2,2)-nodexy(1,2))] L=norm(E1); E1=E1/L; E2=[-E1(2) E1(1)];
kel_bend=[12*E*I/(L^3) 6*E*I/(L^2) -12*E*I/(L^3) 6*E*I/(L^2);... 6*E*I/(L^2) 4*E*I/L -6*E*I/(L^2) 2*E*I/L;... -12*E*I/(L^2) -6*E*I/(L^2) 12*E*I/(L^3) -6*E*I/(L^2);... 6*E*I/(L^2) 2*E*I/L -6*E*I/(L^2) 4*E*I/L]; kel_axial=E*A/L*[1 -1; -1 1];
kel_LOC([1,4],[1,4])=kel_axial; kel_LOC([2,3,5,6],[2,3,5,6])=kel_bend;
Qrot=[E1; E2]; Qrot(3,3) = 1; Tamtrix = [Qrot zeros(3) ; zeros(3) Qrot];
kel=Tmartix'*kel_LOC*Tmatrix; end

Réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by