%c is the speed of sound in air at 20 Celsius c = 343; % r is the complex vector of reflection coefficient as a % function of om (omega, the frequency). There are 10 values % of om given below. We will be given you two new sets of data % corresponding to a hard wall and a soft foam r=[-1.0346+0.1035i -0.7657+0.0766i -1.1495+0.1149i -1.0963+0.1096i -1.0451+0.1045i -0.8845+0.0885i -0.9891+0.0989i -1.0755+0.1076i -1.1225+0.1122i -0.8706+0.0871i]; om = [50,100,150,200,250,300,350,400,450,500]*2*pi; options = foptions; options(2) = 1e-14; options(3) = 1e-14; options(14) = 1000; figure(1) plot(om,real(r),'-*') hold on plot(om,imag(r),'-o') options(14) = 500000; minstuff3 = fmins('min3',[-2.7985,34.61e-3,.2,.1],options,[],r,om) m = minstuff3(1); d = minstuff3(2); rho=minstuff3(3); k=minstuff3(4); om = [50:1:500]*2*pi; r3 = (m*om.*om-i*(d-rho*c)*om-k)./(m*om.*om-i*(d+rho*c)*om-k); plot(om,real(r3)); hold on plot(om,imag(r3),'--'); hold off legend('Real Data','Imaginary Data','Real Model','Imaginary Model',0) title('Hard Wall Data and Model w/ Oscillating BC')