Lecture 32: M-files and programming in Matlab. ---------------------------------------------- %changing working directory pwd ans = H:\ cd h: ls . lcD.ps lecture23.mws .. lecture11.mws lecture24.mws 3.mws lecture12.mws lecture25.mws MATH531 lecture13.mws lecture26.mws Project1 lecture14.mws lecture27.mws Project2 lecture15.mws lecture28.mws data.mat lecture16.mws lecture30.txt hello.dll lecture17.mws lecture31.txt hw5.asv lecture18.mws lecture32.txt hw5.m lecture19.mws review1.mws lambdas.pdf lecture20.mws review2.mws lambdas.ps lecture21.mws sols1.mws lcD.pdf lecture22.mws % see areatriangle.m areatriangle(3,4,5) ans = 6 areatriangle(3,4,5) The area of the triangle (3.000000,4.000000,5.000000) is 6.000000 ans = 6 % see bisect.m and FsquaredMinus2 bisect('FsquaredMinus2', 0, 2, 0.1, 20) The root is in the interval [1.000000,2.000000] m=1.000000, f(m)=-1.000000 The root is in the interval [1.000000,1.500000] m=1.500000, f(m)=0.250000 The root is in the interval [1.250000,1.500000] m=1.250000, f(m)=-0.437500 The root is in the interval [1.375000,1.500000] m=1.375000, f(m)=-0.109375 The root is in the interval [1.375000,1.437500] m=1.437500, f(m)=0.066406 Succeded after 5 steps ans = 1.3750 bisect('FsquaredMinus2', 0, 2, 0.001, 20) The root is in the interval [1.000000,2.000000] m=1.000000, f(m)=-1.000000 The root is in the interval [1.000000,1.500000] m=1.500000, f(m)=0.250000 The root is in the interval [1.250000,1.500000] m=1.250000, f(m)=-0.437500 The root is in the interval [1.375000,1.500000] m=1.375000, f(m)=-0.109375 The root is in the interval [1.375000,1.437500] m=1.437500, f(m)=0.066406 The root is in the interval [1.406250,1.437500] m=1.406250, f(m)=-0.022461 The root is in the interval [1.406250,1.421875] m=1.421875, f(m)=0.021729 The root is in the interval [1.414063,1.421875] m=1.414063, f(m)=-0.000427 Succeded after 8 steps ans = 1.4141 bisect('FsquaredMinus2', 0, 2, 0.0001, 10) The root is in the interval [1.000000,2.000000] m=1.000000, f(m)=-1.000000 The root is in the interval [1.000000,1.500000] m=1.500000, f(m)=0.250000 The root is in the interval [1.250000,1.500000] m=1.250000, f(m)=-0.437500 The root is in the interval [1.375000,1.500000] m=1.375000, f(m)=-0.109375 The root is in the interval [1.375000,1.437500] m=1.437500, f(m)=0.066406 The root is in the interval [1.406250,1.437500] m=1.406250, f(m)=-0.022461 The root is in the interval [1.406250,1.421875] m=1.421875, f(m)=0.021729 The root is in the interval [1.414063,1.421875] m=1.414063, f(m)=-0.000427 The root is in the interval [1.414063,1.417969] m=1.417969, f(m)=0.010635 The root is in the interval [1.414063,1.416016] m=1.416016, f(m)=0.005100 Failed after 10 steps ans = 1.4141 diary off