% hw2_SOLN % Method (1) Use of script and external function % where x(1) = w % x(2) = H1 % x(3) = H2 % x(4) = a % x(5) = b clc clear global L1 L2 h L1 = 12; L2 = 10; h = 3; % starting values xg(1)=min([L1,L2])/2; xg(2)=L1/2; xg(3)=L2/2; xg(4)=xg(1)/2; xg(5)=xg(1)/2; soln = fsolve('placetd_hw2_lab2solver',xg); disp('w = ') disp(soln(1)) % now preparing plot % these are just used to establish reasonable starting values steps = 11; ladder = linspace(10,15,steps); for k = 1 : steps L1 = ladder(k); xg(1)=min([L1,L2])/2; xg(2)=L1/2; xg(3)=L2/2; xg(4)=xg(1)/2; xg(5)=xg(1)/2; soln = fsolve('placetd_hw2_lab2solver',xg); disp('w = ') disp(soln(1)) % save values for plotting xplot(k)=L1; yplot(k)=soln(1); end plot(xplot,yplot) xlabel('Length L1 (ft)') ylabel('Alley width w (ft)') title('placetd\_hw2\_SOLN')