doc fplot pwd ans = \\nask.man.ac.uk\home$\MATLAB edit myf edit startup.m cd P:/public_html/PSBC/ pwd ans = P:\public_html\PSBC ls . 28-Jan-2015.txt test.txt .. 30-Jan-2015.txt edit myf doc function myf(0) ans = 0 myf(1) ans = 0.3415 myf(pi) ans = -1.5708 pi ans = 3.1416 help linspace linspace Linearly spaced vector. linspace(X1, X2) generates a row vector of 100 linearly equally spaced points between X1 and X2. linspace(X1, X2, N) generates N points between X1 and X2. For N = 1, linspace returns X2. Class support for inputs X1,X2: float: double, single See also logspace, colon. Overloaded methods: distributed/linspace codistributor2dbc/linspace codistributor1d/linspace codistributed/linspace Reference page in Help browser doc linspace xs=linspace(0,pi,50); plot(xs, myf(xs)) plot(xs, myf(xs)) plot(xs, myf(xs)) plot(xs, myf(xs)) plot(xs, myf(xs)) myf(1.8) ans = 0.0738 myf(1.7) ans = 0.1417 myf(1.9) ans = -0.0037 pwd ans = P:\public_html\PSBC edit testsolve x=2 x = 2 x=sin(x)/2 x = 0.4546 x=sin(x)/2 x = 0.2196 x=sin(x)/2 x = 0.1089 x=sin(x)/2 x = 0.0543 x=sin(x)/2 x = 0.0272 x=sin(x)/2 x = 0.0136 x=sin(x)/2 x = 0.0068 x=sin(x)/2 x = 0.0034 x=sin(x)/2 x = 0.0017 x=sin(x)/2 x = 8.4860e-04 x=sin(x)/2 x = 4.2430e-04 x=3 x = 3 x=sin(x)/2 x = 0.0706 x=sin(x)/2 x = 0.0353 x=sin(x)/2 x = 0.0176 x=sin(x)/2 x = 0.0088 x=sin(x)/2 x = 0.0044 x=sin(x)/2 x = 0.0022 x=sin(x)/2 x = 0.0011 x=sin(x)/2 x = 5.5064e-04 x=sin(x)/2 x = 2.7532e-04 x=2*sin(x) x = 5.5064e-04 x=2*sin(x) x = 0.0011 x=2*sin(x) x = 0.0022 x=2*sin(x) x = 0.0044 x=2*sin(x) x = 0.0088 x=2*sin(x) x = 0.0176 x=3 x = 3 x=2*sin(x) x = 0.2822 x=2*sin(x) x = 0.5570 x=2*sin(x) x = 1.0573 x=2*sin(x) x = 1.7421 x=2*sin(x) x = 1.9707 x=2*sin(x) x = 1.8422 x=2*sin(x) x = 1.9268 x=2*sin(x) x = 1.8746 x=2*sin(x) x = 1.9084 x=2*sin(x) x = 1.8871 x=2*sin(x) x = 1.9008 x=2*sin(x) x = 1.8921 x=2*sin(x) x = 1.8977 x=2*sin(x) x = 1.8941 x=2*sin(x) x = 1.8964 x=2*sin(x) x = 1.8949 x=2*sin(x) x = 1.8959 x=2*sin(x) x = 1.8953 x=2*sin(x) x = 1.8956 x=2*sin(x) x = 1.8954 x=2*sin(x) x = 1.8956 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=2*sin(x) x = 1.8955 x=3 x = 3 x=3 x = 3 x=3 x = 3 x=3 x = 3 x=3 x = 3 testsolve x = 1.8955 2*sin(x) ans = 1.8955 2*sin(x)-x ans = 4.4409e-16 doc for c=2 c = 2 testsolve x = 1.8955 myf(1.9) {Undefined function or variable 'c'. Error in myf (line 3) y = sin(x) - x/c; } myf(1.9) {Error using / Matrix dimensions must agree. Error in myf (line 3) y = sin(x) - x/c; } c c = 2 global c {Warning: The value of local variables may have been changed to match the globals. Future versions of MATLAB will require that you declare a variable to be global before you use that variable.} c c = [] c=2 c = 2 myf(1.9) ans = -0.0037 fplot(myf,[0,pi]) {Error using myf (line 3) Not enough input arguments. } fplot(myf,[0,pi]) {Error using myf (line 3) Not enough input arguments. } fplot(@myf,[0,pi]) doc fplot c =3 c = 3 fplot(@myf,[0,pi]) c=1 c = 1 fplot(@myf,[0,pi]) fplot(@(x) sin(x),[0,pi]) fplot(@(x) sin(x)./x,[0,pi]) fplot(@(x) [sin(x)./x, sin(x)],[0,pi]) fquad(@(x) sin(x),[0,pi]) {Undefined function 'fquad' for input arguments of type 'function_handle'. } doc fquad quad(@(x) sin(x),[0,pi]) {Error using quad (line 66) The limits of integration must be scalars. } quad(@(x) sin(x),0,pi) ans = 2.0000 doc fzero fzero( @(x) sin(x)-x/2,3) ans = 1.8955 diary off