Q(1) clear all clc a=11; b=9; %could be one long expression s=sqrt(b^2+16*a^2); Labc = s/2 + b^2/(8*a)*log((4*a+s)/b) Conclusion Labc = 24.5637 Q(2) clear, clc V=14; R1=120.6; R2=119.3; R3=121.2; R4=118.8; Vab=V*(R1*R3-R2*R4)/((R1+R3)*(R3+R4)) Conclusion Vab = 0.1071 Q(3) clear, clc T0=98.6; Ts=69; T1=79.5; T2=78; hr=9; min=18; p=log((T1-Ts)/(T0-Ts))/log((T2-Ts)/(T0-Ts)); d=p/(1-p); t1=9+18/60; t_d=t1-d; PM_hd=floor(t_d) PM_md=round(60*(t_d-PM_hd)) Conclusion PM_hd = 2 PM_md = 35 CW1: Student ID: UPXXXXXX Q(4) clear, clc rOA=[2,5,1]; rOB=[1,3,6]; rOC=[-6,8,2]; rAC=rOC-rOA; Volume=dot(rOB,cross(rOC,rAC)) Conclusion Volume = 248 Q(5) clear, clc g=9.81; v0=162; alp=70; t=1:5:31; x=v0*cosd(alp)*t; y=v0*sind(alp)*t - g*t.^2/2; r = sqrt(x.^2+y.^2) teta = atand(y./x) Conclusion r= 1.0e+03 * 0.1574 0.8083 1.2410 1.4759 1.5564 1.5773 1.7176 teta = 69.3893 65.7152 60.5858 53.0831 41.6187 24.0270 0.1812 Q(6) close all clc R=0.08206; T=300; n=1; a=1.39; b=0.0391; V=0.1:.02:1; P_id=n*R*T./V; P_v=n*R*T./(V-n*b)-n^2*a./V.^2; e=100*(P_id-P_v)./P_v; [m ind]=max(e); max_e=m at_vol=V(ind) 1 CW1: Student ID: UPXXXXXX Conclusion max_e = 4.2359 at_vol = 0.2400 Q(7) clear, clc Re=[3 1 1 2 1; 1 2 1 3 1; 1 1 0 3 3; 2 0 3 1 2; 1 2 3 0 2]; ps=16*[128 118 112 112 104]'; res=Re\ps Conclusion res = 320.0000 224.0000 192.0000 256.0000 160.0000 Q(8) clear, clc V1=40; V2=30; V3=36; R1=16; R2=20; R3=10; R4=14; R5=8; R6=16; R7=10; R8=15; R9=6; R10=4; A=[-(R1+R2+R3) R2 R3 0 0; R2 -(R2+R4+R5+R6) R5 R6 R4; ... R3 R5 -(R3+R5+R7) R7 0; 0 R6 R7 -(R6+R7+R8+R9) R8; ... 0 R4 0 R8 -(R4+R8+R10)]; V=[-V1 0 -V2 V3 V1]'; I=A\V %[ I1,I2,I3,I4,I5] 2 CW1: Student ID: UPXXXXXX Conclusion I= 0.7406 -0.6047 0.6161 -1.5316 -2.1649 Q(9) clear, clc vrun=3; vsw=1; L=48; ds=30; dw=42; y=20:1:48; ls = sqrt(y.^2+ds^2); lw = sqrt((L-y).^2+dw^2); t=ls/vrun + lw/vsw; [tmin ind] = min(t); min_t=t(ind) y_at_min=y(ind) pi = atan(y_at_min/ds); alpha = atan((L-y_at_min)/dw); sin_rat=sin(pi)/sin(alpha) speed_rat=vrun/vsw Conclusion min_t = 59.2946 y_at_min = 37 sin_rat = 3.0658 speed_rat = 3 3 CW1: Student ID: UPXXXXXX Discussion: The minimum time is 59.29 seconds with the lifeguard entering the water at 37 m. Snell’s law seems only approximately satisfied, but this is due to the relatively large increment in y. The ratio converges to Snell’s law as the increment decreases. Q(10) close all clc L0=.0254; % L0 in meter r0=.0064; % r0 in meter A0=pi*r0^2; F=[0 13031 21485 31963 34727 37119 37960 39550 ... 40758 40986 41076 41255 41481 41564]; L=[25.4 25.474 25.515 25.575 25.615 25.693 25.752 25.978 ... 26.419 26.502 26.600 26.728 27.130 27.441]/1000; sigmae=F/A0; ee=(L-L0)/L0; sigmat=F.*L/(A0*L0); et=log(L/L0); plot(ee,sigmae,et,sigmat,'--') title('S-S Def') legend('Eng','T','loc','S_E') xlabel('Strain') ylabel('Stress, Pa') Conclusion 4 CW1: Student ID: UPXXXXXX Q(11) close all clc t=0:.01:4; x=4.219*(exp(-1.58*t)-exp(-6.32*t)); v=26.67*exp(-6.32*t)-6.67*exp(-1.58*t); subplot(2,1,1) plot(t,x,'r') title('Railroad Bumper Response') ylabel('Position, m') subplot(2,1,2) plot(t,v,'b') ylabel('Speed, m/s') xlabel('Time, s') Conclusion 5 CW1: Student ID: UPXXXXXX Q(12) close all clc for j=1:2 W=input('Please input your weight in lb: h=input('Please input your height in in: BMI=703*W/h^2; if BMI<18.5 fprintf('\nYour BMI value is %.1f, which asunderweight\n\n',BMI) elseif BMI<25 fprintf('\nYour BMI value is %.1f, which elseif BMI<30 fprintf('\nYour BMI value is %.1f, which overweight\n\n',BMI) else fprintf('\nYour BMI value is %.1f, which end end '); '); classifies you classifies you as normal\n\n',BMI) classifies you as classifies you as obese\n\n',BMI) Conclusion Please input your weight in lb: Please input your height in in: Q(13) close all clc disp('Part (a)') S=[160, -40, 60]; th=20; disp('Stress in x''-y'' coordinate system in MPa') Stran = StressTrans(S,th) disp('Part (b)') S=[-18, 10, -8]; th=20; disp('Stress in x''-y'' coordinate system in ksi') Stran = StressTrans(S,65) function Stran = StressTrans(S,th) Stran(1)=0.5*(S(1)+S(2)) + 0.5*(S(1)-S(2))*cosd(2*th) + S(3)*sind(2*th); Stran(2)=S(1)+S(2)-Stran(1); Stran(3)=-0.5*(S(1)-S(2))*sind(2*th) + S(3)*cosd(2*th); end 6 CW1: Student ID: UPXXXXXX Conclusion Part (a) Stress in x'-y' coordinate system in MPa Stran = 175.1717 -55.1717 -18.3161 Part (b) Stress in x'-y' coordinate system in ksi Stran = -1.1293 -6.8707 15.8669 Q(14) close all clc t=linspace(0,10,100); r=8+0.6*t; phi=5*pi*t/180; theta=8*pi*t/180; x=r.*cos(phi).*cos(theta); y=r.*cos(phi).*sin(theta); z=r.*sin(phi); plot3(x,y,z,'k','linewidth',1) grid on xlabel('x (m)'); ylabel('y (m)'); zlabel('z (m)') view(45,30) Conclusion 7 CW1: Student ID: UPXXXXXX Q(15) close all clc p=15; rd=3; E=10E6; t=0.08; nu=0.3; K=E*t^3/(12*(1-nu^2)); K1=330;%K in MPa C=p*rd^4/(64*K); [th,r] = meshgrid((0:5:90)*pi/180,0.02:0.01:0.14); [X,Y] = pol2cart(th,r); Sx=K1./sqrt(2*pi*r).*cos(th/2).*(1-sin(th/2).*sin(3*th/2)); Sy=K1./sqrt(2*pi*r).*cos(th/2).*(1+sin(th/2).*sin(3*th/2)); Sxy=K1./sqrt(2*pi*r).*cos(th/2).*sin(th/2).*cos(3*th/2); mesh(X,Y,Sx) xlabel('x (in.)'), ylabel('y (in.)'), zlabel('Sx (ksi)') Conclusion 8