% This m-file animates the static solution to a simply supported beam with % a load P moving from the left end 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)*(1-x1overL(1,k)) -x1overL(1,k)*(ones(1,101-k)) ]; V=[V;V1]; M1=[(1-x1overL(1,k))*xoverL(1,1:k)]; M2=[x1overL(1,k)*(ones(1,101-k)-xoverL(1,k+1:101))]; M=[M;M1 M2]; end V=[V;zeros(1,101)]; M=[M;zeros(1,101)]; xarrow=[0 0 .02 -.02 0]; yarrow=[1 .01 .05 .05 .01]; figure(1);clf; axis([-.1 1.1 -.1 1.4]) hold on xlabel('Dimensionless Distance, x/L'); hold on ylabel('Dimensionless Load, Load/P'); hold on plot(xoverL,zeros(1,101),'LineWidth',[2.5],'Color','k'); hold on plot([-.1 0],[0 0],'k'); hold on plot([1 1.1],[0 0],'k'); hold on plot([0 1],[0 0],'o') 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,1.2,'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 -2.1 2.1]); 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.6,'Press Enter to Continue'); pause 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 .3]); 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,.25,'Press Enter to Continue'); pause 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 %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 y1=-(y1-y1(1,101)*xoverL); y=[y;y1]; end figure(5);clf; yarrow=-[.008 .0005 .001 .001 .0005]; axes('Ydir','reverse') hold on axis([-.1 1.1 -.01 .025]); hold on xlabel('Dimensionless Distance, x/L'); hold on ylabel('Dimensionless Deflection, y(x)EI/PL^3'); hold on plot([-.1 0],[0 0]); hold on plot([1 1.1],[0 0]); hold on plot([0 1],[0 0],'o') hold on deflection=plot(xoverL,y(1,:),'EraseMode','xor','LineWidth',[3]); a3=plot(xarrow,yarrow,'LineWidth',[2],'Color','k','EraseMode','xor'); t1=text(.6,-.005,'Press Enter to Continue'); pause plot([-.1 1.1],[0 0],'k'); hold on for k=2: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