Answered step by step
Verified Expert Solution
Question
1 Approved Answer
using Matlab Create a MATLAB function that plots with fplot a mathematical function with limits for x determined according to the instructions below. The function
using Matlab
Create a MATLAB function that plots with fplot a mathematical function with limits for x determined according to the instructions below. The function should be implemented in the auto_fplot.m file provided Output = auto_fplot (func) Inputs: a mathematical function in x in symbolic form (func) Output: a cell array as described below. This auto_fplot function should meet the following requirements. 1) After the mathematical function has been plotted the auto_fplot function should be able to plot a set of interesting points (i.e. local maxima, local minima, inflection points, and two points for each vertical asymptote) for as many types of functions as possible. These should work for any polynomial equation. Vertical asymptotes should work for any rational function. All local maxima should be indicated with red circles, all local minima should be indicated with green circles and all inflection points should be indicated with blue circles. Vertical asymptotes should be indicated with black 'x's on the bottom and top borders (the fplot function of MATLAB draws dashed lines for the vertical asymptotes automatically). Each type of point must be drawn in that order if that type of point exists for the mathematical function. For each type, all points of that type must be plotted all at once and only if at least one point of that type exists. The "region of interest" or "domain of interest" (1.e. portion between the two extreme interesting points if there is a finite number of such points) should be in the middle and occupy 70% of the x limits of the plot. If there is no interesting point found (or an infinite number of interesting points), plot the mathematical function and set the limits of x to be from -20 7 to 20 7. And if there is only one interesting point, Xinteresting, then set the limits of x to be from (Xinteresting -20 ) to (Xinteresting + 20 ). Function auto_fplot returns the following Output = {fplotH; ImaxPlot, IminPlot, inflPlot; verAsymPlotBottom); where fplotH returns the function line object returned for the plot of f(x), and the other objects are the lineseries/line objects returned for the plots of the local maxima, local minima, inflection points, and the bottom markers for vertical asymptotes. 2) The mathematical function as a title, axes labels (i.e., 'x' for x axis and 'f(x) for y axis) and legend (.e., 'f(x)', 'Local Maxima', 'Local Minima', 'Inflection Points', and 'Vert. Asymptotes' as needed) should be included in the plot. Please make sure all your strings match these instructions. Only include in the legend those types of interesting points that exist for the mathematical function being plotted. These legend entries should be shown as plural even if there is only one point of a certain type. 3) Please complete the help comments at the top of the file. Do not modify the characters %output = AUTO FPLOT (f before the "..." Bonus requirements: 4) Can you include the location of any horizontal asymptotes? A left horizontal asymptote can be plotted as a green x on the left border, and a right horizontal asymptote can be plotted as a red 'x' on the right border. Plot the left horizontal asymptote value, if it exists, after all points mentioned in paragraph 1 above, and plot the right horizontal asymptote value, if it exists, last. Depending on which horizontal asymptote(s) may or may not exist, the legend can have entries Left Asymptote" and/or "Right Asymptote (note that these are grammatically singular). 1 Assuming the bonus in paragraph 5 is not implemented. 5) (a) If the input is a periodic function, plot 2 periods of the function including the point fo) (b) try to plot maxima, minima, inflection points, and vertical asymptotes in the 2 periods as described in paragraph 1 and (c) hopefully with a periodic maximum at the left and right borders of the plot. 6) If you believe that some interesting points exist, but you cannot solve for them symbolically, just remove those interesting points from the collection that you are considering and then apply the rules to any remaining interesting points to determine the x limits of the figure. Your implementation will likely be evaluated using a set of test functions, and some mathematical test functions may be provided. In any case, write your own mathematical functions to test your auto_fplot function against. Your auto_fplot function should work for any reasonable mathematical function, especially simple functions. You have been warned! For now, you can test your auto_fplot function with mathematical functions including those shown in Question 1 and Question 2. Students in the class are highly encouraged to share their mathematical testing functions on Piazza. You can also include your output figures for other students to compare with Create a MATLAB function that plots with fplot a mathematical function with limits for x determined according to the instructions below. The function should be implemented in the auto_fplot.m file provided Output = auto_fplot (func) Inputs: a mathematical function in x in symbolic form (func) Output: a cell array as described below. This auto_fplot function should meet the following requirements. 1) After the mathematical function has been plotted the auto_fplot function should be able to plot a set of interesting points (i.e. local maxima, local minima, inflection points, and two points for each vertical asymptote) for as many types of functions as possible. These should work for any polynomial equation. Vertical asymptotes should work for any rational function. All local maxima should be indicated with red circles, all local minima should be indicated with green circles and all inflection points should be indicated with blue circles. Vertical asymptotes should be indicated with black 'x's on the bottom and top borders (the fplot function of MATLAB draws dashed lines for the vertical asymptotes automatically). Each type of point must be drawn in that order if that type of point exists for the mathematical function. For each type, all points of that type must be plotted all at once and only if at least one point of that type exists. The "region of interest" or "domain of interest" (1.e. portion between the two extreme interesting points if there is a finite number of such points) should be in the middle and occupy 70% of the x limits of the plot. If there is no interesting point found (or an infinite number of interesting points), plot the mathematical function and set the limits of x to be from -20 7 to 20 7. And if there is only one interesting point, Xinteresting, then set the limits of x to be from (Xinteresting -20 ) to (Xinteresting + 20 ). Function auto_fplot returns the following Output = {fplotH; ImaxPlot, IminPlot, inflPlot; verAsymPlotBottom); where fplotH returns the function line object returned for the plot of f(x), and the other objects are the lineseries/line objects returned for the plots of the local maxima, local minima, inflection points, and the bottom markers for vertical asymptotes. 2) The mathematical function as a title, axes labels (i.e., 'x' for x axis and 'f(x) for y axis) and legend (.e., 'f(x)', 'Local Maxima', 'Local Minima', 'Inflection Points', and 'Vert. Asymptotes' as needed) should be included in the plot. Please make sure all your strings match these instructions. Only include in the legend those types of interesting points that exist for the mathematical function being plotted. These legend entries should be shown as plural even if there is only one point of a certain type. 3) Please complete the help comments at the top of the file. Do not modify the characters %output = AUTO FPLOT (f before the "..." Bonus requirements: 4) Can you include the location of any horizontal asymptotes? A left horizontal asymptote can be plotted as a green x on the left border, and a right horizontal asymptote can be plotted as a red 'x' on the right border. Plot the left horizontal asymptote value, if it exists, after all points mentioned in paragraph 1 above, and plot the right horizontal asymptote value, if it exists, last. Depending on which horizontal asymptote(s) may or may not exist, the legend can have entries Left Asymptote" and/or "Right Asymptote (note that these are grammatically singular). 1 Assuming the bonus in paragraph 5 is not implemented. 5) (a) If the input is a periodic function, plot 2 periods of the function including the point fo) (b) try to plot maxima, minima, inflection points, and vertical asymptotes in the 2 periods as described in paragraph 1 and (c) hopefully with a periodic maximum at the left and right borders of the plot. 6) If you believe that some interesting points exist, but you cannot solve for them symbolically, just remove those interesting points from the collection that you are considering and then apply the rules to any remaining interesting points to determine the x limits of the figure. Your implementation will likely be evaluated using a set of test functions, and some mathematical test functions may be provided. In any case, write your own mathematical functions to test your auto_fplot function against. Your auto_fplot function should work for any reasonable mathematical function, especially simple functions. You have been warned! For now, you can test your auto_fplot function with mathematical functions including those shown in Question 1 and Question 2. Students in the class are highly encouraged to share their mathematical testing functions on Piazza. You can also include your output figures for other students to compare withStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started