EXERCISES anonymous fu I Creation and evaluation of 28 L Cre



EXERCISES anonymous fu I. Creation and evaluation of 2.8 L Create th 2.8 f(r) and f( f(r) where a f(z), and plot zi an (a) Find foo), and evaluate evaluate (b) Vectorize f linspace (-1,1), single (c) Create three commands into third command to (d) the following get at the end of the plot (x,y) the plot that you (-1, 1) y f (x) x linspace from (e) Use f plot graph -w C with multiple anonymous functions: mous functions corresponding to the following expressions: 8a3 17r thre f(z) g(r) h (z) (a) Evaluate f(r) g(r)h(z) at r 3. (b) Evaluate f(r) g(r)h(z) at r (1 2 3 4 5 (c) Evaluate h(r) for any r (d) Plot f(r) and over z e -5, 5 3. Anonymous functions as the input to other functions: Use the sam function f(r) previously, i.e., f(r) r 8ac3 17a2 the following tasks (a) Plot the function using fplot over an appropriate interval of and low the zeros of the function on the graph (that is, find all ar for w (b) Learn about the built-in function fzero that finds the zero of any t function accurately, making Now use fzero to find the zeros made above. approximate initial guesses based on the plo (c) Use function quad to integrate f(r) from 0 to 1 and veri results by direct integration. 4. Anonymous functions of several vari compound interest on an invetm

Solution

Declaration Window:

function [v] = f(x)
%this function computes the value for annonymous expression x4-8x3+17x2-4x-20
% It takes x value as input argument

v = (x*x*x*x)-(8*x*X*x)+(17*x*x)-(4*x)-20;
end % end of f

function [v] = g(x)
%this function computes the value for annonymous expression x2-4x+4
% It takes x value as input arguments

v = (x*x)-(4*x)+4;
end % end of g

function [v] = h(x)
%this function computes the value for annonymous expression x2-4x-5
% It takes x value as input argument

v = (x*x)-(4*x)-5;
end % end of h

command window:

x=3;
r=f(x)-g(x)*h(x);

disp(r);

n=[1,2,3,4,5];
r=f(n)-g(n)*h(n);

disp(r);

x=2;
r=(f(x)/q(x))-h(x);

disp(r);

x=linspace(-5,5);
plot(x,f(x));

x=linspace(-5,5);
plot(x,(f(X)/(g(x)*h(x)));

 EXERCISES anonymous fu I. Creation and evaluation of 2.8 L Create th 2.8 f(r) and f( f(r) where a f(z), and plot zi an (a) Find foo), and evaluate evaluate (b)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site