Question

popcorn while using less paper to manufacture them. il l suript can help manufacturers of popcorn tubs to optimize it to carry Q5. The polynomial y is defined as (20 points) y 2 x4-7 x3- 44 x92.5 x262.5 (a) In a script file, Initials_MT_Pb_05.m, define y using an anonymous function. (b) Use the anonymous function to evaluate y when x-3, x-0, x-3. (c) Use the anonymous function handle to plot y for-4sxS 5.5 Hint: Use fplot. (d) Use the plot you generated in part (c) to get an estimate of the location of zeros then use proper command to find the exact location of all the zeros of the anonymous function ha x01 (e) Use the plot you generated in part (c) to get an estimate of the location of the minimums proper function to find the 2 minimum values of y and the corresponding x values. [xminl, yminl]-
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find required MATLAB code along with necessary details in comments:

clear all; % clear workspace
close all; % close all figures
clc % clear command window

%% define anonymus function
y=@(x) (2*x^4) -(7*x^3) -(44*x^2) + 92.5*x +262.5;

%% evalaute function value at x=-3, 0, 3
y_n3=y(-3)
y_0=y(0)
y_3=y(3)

%% plot the function
h1=fplot(y,[-4,5.5]);  
grid on;
hold on
h2=fplot(0); % plot x-axis

%% locate all zeros in the function plot using initial estimates
% obtained from the graphs

% x = fzero(fun,x0) tries to find a point x where fun(x) = 0. This solution
% is where fun(x) changes sign—fzero cannot find a root of a function such as x^2.

x01=fzero(y,-4)
x02=fzero(y,-2)
x03=fzero(y,4)
x04=fzero(y,5)

% plot the zeros for ease of reference
h3=plot([x01;x02;x03;x04],[0;0;0;0],'r*');

%% Locate the minimum of function value from the estmates obtained from the
% graph

% x = fminsearch(fun,x0) starts at the point x0 and attempts to find a
% local minimum x of the function described in fun.

[xmin1,ymin1] = fminsearch(y,-3)
[xmin2,ymin2] = fminsearch(y,5)

% plot the minimum for ease of reference
h4=plot([xmin1;xmin2],[ymin1;ymin2],'bs');
legend([h1,h2,h3,h4],{'y(x)','x-axis','Zeros','Local Minima'});

-------------------------------------- SCREENSHOT OF CODE

Initial-MT-Pb-05.m ×1 + clear all; close all; clc clear workspace close all figures clear command window % define anonymus function ye@ (x) (2*x4) -(7*xЗ) -(44#x2 ) + 92 . 5 *x +262.5; %% evalaute function value at x -3, 0, 3 Y Oy (0) yー3型(3) 12 13 plot the function hl=fplot (y, [-4, 5 . 5] ) ; grid on; hold on h2-fplot (0); 16 % plot x-axis 18 19 20 21 %% locate all zeros in the function plot us ing initial estimates obtained from the graphs x = fzero (fun,x0) tries to find a point x where fun (x) = 0. This solution 23 24 is where fun (x) changes sign-fzero cannot find a root of a function such as x^2. x01-fzero (y,-4) x02-fzero (y,-2) x03-fzero (y, 4) x04-fzero (y, 5) 26- t plot the zeros for ease of reference

-------------------------------------------------------------------------------- SAMPLE OUTPUT

Add a comment
Know the answer?
Add Answer to:
popcorn while using less paper to manufacture them. il l suript can help manufacturers of popcorn...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help me out by giving me detailed answers with formulas. So I can understand fully...

    Please help me out by giving me detailed answers with formulas. So I can understand fully Thank you very much A study is conducted to examine the influence of ‘screen time’ on student performance on Statistics exams. A class of 12 students is observed over a period of time, with the independent variable being the average amount of time per day each student spends on TV/internet, and the dependent variable being their subsequent Statistics exam score, in %. The data...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT