% Elastic bar fixed at the left end and free at the right end with % suddenly applied impulse of intensity I0 at the free end. % There is no initial deformation and % no initial deformation rate. % 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); xoverL=linspace(0,1,101); ctoverL=linspace(0,4,401); framedata=[]; pulse=ones(1,100); zeroo=zeros(1,100); w=-[zeroo zeroo -pulse -pulse zeroo zeroo pulse pulse zeroo zeroo -pulse -pulse]; for t=1:401 framedata=[framedata; w(1,500+t:600+t)+w(1,501-t:601-t)]; end figure(1);clf; axis([-.2 1.2 -1.5 1.5]) hold on xlabel('Dimensionless Distance, x/L') hold on ylabel('Dimensionless Displacement, \mucu(x,t)/I_0') S=plot(xoverL,framedata(1,:),'k','EraseMode','xor');%,'LineWidth',2); text(-.1,1.3,'Press Enter to Continue') box on pause for k=11:10:401 set(S,'Ydata',framedata(k,:)); text(-.1,1.3,'Press Enter to Continue') pause end figure(2);clf; axis([0 4 -2.2 2.2]) hold on text(9,2.1,'x/L=') box on for j=1:10:101 plot(ctoverL,framedata(:,j)) hold on text(9,framedata(301,j),num2str(xoverL(1,j))) hold on end xlabel('Dimensionless Time, ct/L') ylabel('Dimensionless Displacement, \mucu(x,t)/I_0') text(6,8,'Press Enter to Continue') pause %now do animation figure(3);clf; axis([-.2 1.2 -1.5 1.5]) hold on box on xlabel('Dimensionless Distance, x/L') hold on ylabel('Dimensionless Displacement, \mucu(x,t)/I_0') hold on L=plot(xoverL, zeros(1,101),'k','EraseMode','xor');%,'LineWidth',2); texthandl1=text(-.1,1.3,'Press Enter to Set Initial Condition'); pause set(L,'Ydata',framedata(1,:)) set(texthandl1,'String','Press Enter to Animate'); pause set(texthandl1,'String',' '); for i=2:401 set(L,'Ydata',framedata(i,:)) pause(.03) end hold on set(texthandl1,'String','Press Enter to Continue'); pause figure(4);clf; xpow=[1.1 1.02 1.05 .95 .88 .92 .9 1.01 1.04 1.03 1.1]+.13*ones(1,11); ypow=-5*[.1 .14 .17 .13 .15 .07 .04 .06 .05 .08 .1]+.5*ones(1,11); axis([-.2 1.4 -1 1]); ypatch=[-.5 .5 .3 -.1 -.35 -.5]; xpatch=[0 0 -.15 -.04 -.17 0]; patch(xpatch, ypatch,'r'); hold on box on xlabel('Dimensionless Distance, x/L'); xbar=[0 1 1 0]; ybar=[.2 .2 -.2 -.2]; bar=plot(xbar, ybar,'Color', 'k','LineWidth',[2],'EraseMode','xor'); ytic=[-.18 .18]; for i=1:19 tic(1,i)=plot([i*.05 i*.05],ytic,'EraseMode','xor'); end t1=text(.5,.8,'Press Enter to Set Initial Condition'); pause set(bar, 'Xdata', xbar); for i=1:19 set(tic(1,i), 'Xdata',[i*.05+.03*framedata(1,i*5+1) i*.05+.03*framedata(1,i*5+1)]); end POW=patch(xpow,ypow,'m'); set(t1,'String','Press Enter to Animate '); pause set(POW,'Visible','off') set(t1,'String',' '); for k=2:401 set(bar,'Xdata', [0 1+.03*framedata(k,101) 1+.03*framedata(k,101) 0]); for i=1:19 g=i*.05+.03*framedata(k,i*5+1); set(tic(1,i), 'Xdata',[ g g]); end pause(.03) end set(bar,'Xdata', xbar); set(t1,'String', 'Press Enter to Continue') pause