Write a program that creates three anonymous functions representing the function
ID: 3831910 • Letter: W
Question
Write a program that creates three anonymous functions representing the functions f(x) = 10 cosx, g(x) = 5 sin x, and h(a, b) = Squareroot (a^2 + b^2). plot h(f(x), g(x)) over the range -10 lessthanorequalto x lessthanorequalto 10. Function fminbnd can be used to find the minimum of a function over a user- defined interval. Find the minimum of the function y(x) = x^4 - 3x^2 + 2x over the interval (0.5 1.5). Use an anonymous function for y(x). Plot the function y(x) = x^4 - 3x^2 + 2x over the range (-2, 2). Then use function fminbnd to find the minimum value over the interval (-1.5, 0.5). Did the function find the minimum value over that region? What is going on there? Write a program that locates that zeros of the function f (x) = cos^2 x - 0.25 between 0 and 2 pi. Use the function fzero to locate the zeros of this function. Plot the function over that range and show that fzero has reported the correct values. Data x is a linearly spaced row vector of length 35 between -1 and 1. Data y is a function of x: y = 6x + 2 + noise. plot data x - y, construct the linear model of the x-y data using Least Squares Regression method. Plot the linear model x = [0.6 1.5 2.2 3.1 4.6 6.1 7.5]; y = [0.4 2.5 3.15 1.1 3.5 4.9 6.3]; Use a polynomial to curve fit the x-y data, so that the curve can pass all the x-y data. Plot this polynomial using 50 points Check if the curve passes all the x-y data. f(x) = 1/(x^3 + 3x^2 - 4* x - 1). Use both anonymous function and inline function to calculate the integral of f(x) on the domain [-1 2]Explanation / Answer
This is long assignment to do at once. providing you the solution for 4 question. Please post the remaining questions again.
%Answer1
f=@(x) 10*cos(x);
g=@(x) 5*sin(x);
h=@(x,y) sqrt(x^2+y^2);
fplot(h(f,g),[-10 10],'b')
%Answer2
f=@(x) x.^4-3*x.^2+2*x;
y=fminbnd(f,0.5,1.5);
%Answer3
fplot(@(x) x.^4-3*x.^2+2*x,[-2 2],'b')
y=fminbnd(f,-1.5,0.5)
%Answer7
%Define the anonymous functon
f = @(x) 1/(x.^3+3*x.^2-4*x-1);
q = integral(f,-1,2);
% Define the inline functon 'z'
z = inline('1/(x^3+3*x^2-4*x-1)','x');
q = integral(f,-1,2);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.