% This m-file animates the static solution to a cantilever % beam with a load P moving from the left end (the root) to the right end. % This m-file was written at the University of Wyoming in the Electrical % and Computer Engineering Department and is to be distributed without % cost. clear all set(0,'DefaultAxesFontSize',12); set(0,'DefaultTextFontSize',12); x1overL=linspace(0,1.3,131); xoverL=linspace(0,1,101); %V=[1 zeros(1,100)]; %M=[zeros(1,101)]; V=[1 zeros(1,100)]; M=[zeros(1,101)]; for k=2:100 V1=[ones(1,k) zeros(1,101-k)]; V=[V;V1]; M1=[-x1overL(1,k)*ones(1,k)+xoverL(1,1:k) zeros(1,101-k)]; M=[M;M1]; end V=[V;ones(1,101)]; M=[M;-x1overL(1,101)*ones(1,101)+xoverL(1,1:101)]; xarrow=[0 0 .02 -.02 0]; yarrow=[.1 .001 .02 .02 .001]; xpatch=[-.001 -.001 -.08 -.06 -.07 -.01]; ypatch=[-.08 .1 .07 .04 -.04 -.08]; figure(1);clf; axis([-.1 1.1 -.1 .2]) hold on xlabel('Dimensionless Distance, x/L'); hold on ylabel('Dimensionless Load, Load/P'); hold on plot(xoverL,zeros(1,101),'LineWidth',[4],'Color','k') hold on plot([-.1 0],[0 0],'k'); hold on plot([1 1.1],[0 0],'k'); hold on patch(xpatch,ypatch,'r') hold on plot([-.05 0],[0 0],'LineWidth',[4],'Color','k'); hold on a1=plot(x1overL(1,1)*ones(1,5)+xarrow,yarrow,'EraseMode','xor','LineWidth',[2]); %a2=plot((xoverL(1,1)-.3)*ones(1,5),yarrow,'EraseMode','xor'); t5=text(.6,.15,'Press Enter to Continue'); pause set(t5,'String',' ') for k=1:101 set(a1,'Xdata',x1overL(1,k)*ones(1,5)+xarrow); %set(a2,'Xdata',(x1overL(1,k)-.3)*ones(1,5)+xarrow); pause(.06) end set(t5,'String','Press Enter to Continue') pause figure(2);clf; axis([-.1 1.1 -.5 1.5]); hold on xlabel('Dimensionless Distance, x/L'); hold on ylabel('Dimensionless Shear, V/P'); hold on plot([-.1 1.1],[0 0],'k'); shear=plot(xoverL,V(1,:),'EraseMode','xor'); t1=text(.6,1.2,'Press Enter to Continue'); pause set(t1,'String',' '); plot([-.1 1.1],[0 0],'k'); hold on for k=1:101 set(shear,'Ydata',V(k,:)); pause(0.06) end plot([-.1 1.1],[0 0],'k'); box on plot([-.1 1.1],[0 0],'k'); set(t1,'String','Press Enter to Continue') pause figure(3);clf; axis([-.1 1.1 -1.1 .1]); hold on plot([0 0],[-1.1 .1]); hold on xlabel('Dimensionless Distance, x/L'); hold on ylabel('Dimensionless Moment, M/PL'); hold on plot([-.1 1.1],[0 0],'k'); moment=plot(xoverL,M(1,:),'EraseMode','xor'); t1=text(.6,-.8,'Press Enter to Continue'); pause set(t1,'String',' ') for k=1:101 set(moment,'Ydata',M(k,:)); pause(0.06) end plot([-1.1 .1],[0 0],'k'); box on set(t1,'String','Press Enter to Continue') pause %calculate slope and deflection yprime=[zeros(1,101)]; for k=2:101 yprime1=zeros(1,101); for i=1:101 yprime1(1,i)=-(sum(M(k,1:i))-(M(k,i)/2))*.01; end yprime=[yprime;yprime1]; end yprime(:,1)=zeros(101,1); %calculate deflection y=zeros(1,101); for k=2:101 y1=zeros(1,101); for i=1:101 y1(1,i)=(sum(yprime(k,1:i))-(yprime(k,i)/2))*.01; end y=[y;y1]; end figure(5);clf; yarrow=[-.08 -.005 -.02 -.02 -.001]; ypatch=[-.08 .1 .07 .04 -.03 -.08]; axes('Ydir','reverse') hold on axis([-.1 1.1 -.1 .4]); hold on plot([0 0],[-.1 .4]) xlabel('Dimensionless Distance, x/L'); hold on ylabel('Dimensionless Deflection, y(x)EI/PL^3'); hold on patch(xpatch,ypatch,'r') hold on plot([-.05 0],[0 0],'LineWidth',[2.5],'Color','k'); hold on deflection=plot(xoverL,y(1,:),'EraseMode','xor','LineWidth',[3],'Color','k'); a3=plot(xarrow,yarrow,'EraseMode','xor','LineWidth',[2],'Color','b'); t1=text(.6,-.05,'Press Enter to Continue'); pause plot([-.1 1.1],[0 0],'k'); hold on set(t1,'String',' ') for k=1:101 set(deflection,'Ydata',y(k,:)); set(a3,'Xdata',xarrow+xoverL(1,k),'Ydata',yarrow+y(k,k)); pause(0.06) end plot([-.1 1.1],[0 0],'k'); hold on box on set(t1,'String','Press Enter to Continue') pause