Write a function in matlab and then a program that has the following: Consider t
ID: 2083236 • Letter: W
Question
Write a function in matlab and then a program that has the following:
Consider the function f(x) = e^-0.4 x cos x - 0.3. a) Plot the function using fplot for - 2 lessthanorequalto x lessthanorequalto 8. Using the plot, visually estimate and report the approximate locations of its minimum and maximum points. b) Use the fminbnd function to precisely determine the locations of the minimum point. c) Use the fminbnd function to precisely determine the location of the maximum point. d) Use the fzero function to find all the solutions to the equation f(x) = 0.Explanation / Answer
clc;
close all;
clear all;
%x = 0:8;
%QUESTION 1
fx1 = @(x) (exp(-0.4*x)*cos(x))-0.3 ;
fplot(fx1,[-2 8]);
%FROM THE GRAPH, THE maximum point will be around -0.3 and
% the maximum will be around 2.5
%QUESTION 2
x_min = fminbnd(fx1,-2,8)
%QUESTION3
% SOLUTION IS TO MIRROR VERTICALLY
fx2 = @(x) -((exp(-0.4*x)*cos(x))-0.3) ;
x_max = fminbnd(fx2,-2,8)
%QUESTION 4
x_zero = fzero(fx1,0)
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.