Thank you ! 1. probi.m Create an anonymous function for the following function:
ID: 3597442 • Letter: T
Question
Thank you !
1. probi.m Create an anonymous function for the following function: y(x) = -20x2 + 200x – 3 Use the anonymous function and findbnd to determine the location and value of the maximum, and print these to the window. 2. prob2.m What are the coordinates of the intersection of the following two lines: y1 = x2 + 3x – 4 y2 = 3x You can use either fzero or fsolve. With fzero, youll need to find each intersection separately, with fsolve, you can add a vector input of guesses to get both points simultaneously. Print answer to the command window.Explanation / Answer
1.
% using fminbind if negate the function then we get the max value for the function hence a -1 is multiplied to the % original function -1000 to 1000 is the specified rangein which the search would happen it can be any range
% In this case a range of -1 to 1 would also give the same result .
% maxl stores the point at which max happens and because the function is made -ve , fval is again multiplied by -1 % to get the max value
% @x Creates a function handle for your function for an anonymous fuction
[maxl,fval] = fminbnd(@(x) -1*(-200*x.^2 + 200*x - 3),-1000,1000)
disp(maxl)
disp((-1)*fval)
2.
% At points of intersection y1 = y2 or y1-y2 = 0 , so if we define a y3 = y1 - y2 and equate to 0 using fzero it would % give us the points of intersection where y3 = 0 for different values of x
y3 = @(x) x.^2 +3*x - 4 -3*x ;
x = -3:0.1:3; % define range of values for plot using 0.1 as the interval within range - 3 to 3
% If we plot this we can view y3 where it is 0
plot(x,y3);
% where it is found to be zero on plot are the points of intersection which can be verified using fzero
% As the function on simplification is x^2 - 4 so we can see it would equate to zero at 2 and -2
disp(FZ);
disp(SZ);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.