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}