Page 4 - Demo
P. 4


                                    Planar TrussExamplefor ComrelAdd-onRCPConsult, 2022-2025Page 4d =setdiff(1:ndof,c);// free dofs //! Remove supports from force vectorfc(c)=[];// f = equivalent nodal force vector// q = equilibrium nodal force vector// a = displacements//| qd | | Kcc Kcd || ac | | fd |//| | = | || | -| |//| qc | | Kdc Kdd || ad | | fc |//! Solve the system of equationsKcc =K(c,c);Kcd =K(c,d);Kdc =K(d,c);Kdd =K(d,d);ac =[0;0;0];// displacements for c are 0ad =Kdd\\(fc-Kdc*ac);// = linsolve(Kdd, fc-Kdc*ac)qd =Kcc*ac +Kcd*ad;//! Final displacementsa =zeros(ndof,1);q =zeros(ndof,1);a(c)=ac;q(c)=qd;a(d)=ad;// q(d) = qc = 0//! Axial loads in barsN =zeros(nfe,1);fore =1:nfeN(e)=k(e)*[-1010]*T{e}*a(LM{e});end// Return value of script (function)lsfval =a(8);// vertical deflection at bottom center (N04)//! VisualizationifStrurelPlotthen// begin of plot blockif(StrurelMode==0||StrurelMode==2)then// X and Y coordinates in mXY =[00;40;80;120;160;200;240;222;182;142;102;62;22];// deflection vectorb=matrix(a,[2,nnp])';// forces with scale factor 0.0005fc =zeros(ndof,1);fc(162:26)=P;d=matrix(fc,[2,nnp])'*0.00005;// deformed coordinates with scale factor 2.DEF =XY +b*2// resolution of screenpxl =get(0,\selectStrurelModecaseint32(0)tit='Planar Truss -Deterministic Solution';// 0 -initial deterministic solutionnf=0;caseint32(2)tit='Planar Truss Stochastic Solution';// 2 final stochastic solutionnf=1;end//! Create 3 plotsforf =13nf=f+nf;switch(f)case1// plot for initial and deformed statesscf(nf);figure(nf,'Name',tit,'position',[pxl(3)/4pxl(4)/4pxl(3)/2pxl(4)/2]);// plot framereplot([222610]);mtlb_axis('equal');xgrid(2);// set a main subtitle of plotxstring(8.0,8.0,'$\\textcolor{blue}{Initial}\\textcolor{black}\\,and\\,\\textcolor{red}{deformed}\\textcolor{black}\\,{states}
   1   2   3   4   5   6   7   8   9   10

 

 

 

 

 

);gce().font_size=5;// plot initial and deformed states of trussfore =1:nfeplot(XY(IEN(e,:),1),XY(IEN(e,:),2),'b-','LineWidth',2);// blue color for initial stateplot(DEF(IEN(e,:),1),DEF(IEN(e,:),2),'r-,'LineWidth',2);// red color for deformed statex=(XY(IEN(e,1),1)+XY(IEN(e,2),1))/2;y=(XY(IEN(e,1),2)+XY(IEN(e,2),2))/2;xstring(x,y,strcat(['R',string(e)]));gce()font_size=3;// rod number in the middle of rod lengthend// plot nodal numbersplot(XY(:,1),XY(:,2),'r*');fore =1:nnpxstring(XY(e,1),XY(e,2),strcat(['N',string(e)]));gce()font_size=3;end// value of vertical deflection in node N04xstring(DEF(4,1),DEF(4,2)-0.5,sprintf('$U\\\\,=\\\\,%g m
   1   2   3   4   5   6   7   8   9   10

 

 

 

 

 

,b(4,2)));gce().font_size=3;// plot vertical forcesn=0;fori =1:nnpif(d(i,2)>0.001)xarrows([XY(i,1)+d(i,1)XY(i,1)],[XY(i,2)+d(i,2)XY(i,2)],5,1);gce()thickness=2;// single vectorn=n+1;Pn=strcat(['$P',string(n)]);xstring(XY(i,1)+0.1+d(i,1),XY(i,2)+d(i,2),strcat([Pn,sprintf('=%g\\\\,N
   1   2   3   4   5   6   7   8   9   10

 

 

 

 

 

,d(i,2)*20000)]));gce().font_size=2;// force valueendendcase2// plot for internal member forces Nscf(nf);figure(nf,'Name',tit,'position',[pxl(3)/4pxl(4)/4pxl(3)/2pxl(4)/2]);// plot framereplot([222610]);mtlb_axis('equal');xgrid(2);
   1   2   3   4   5   6   7   8   9   10