Page 1 of 1

USE MATLAB

Posted: Sun May 15, 2022 10:03 am
by answerhappygod
USE MATLAB
Use Matlab 1
Use Matlab 1 (50.34 KiB) Viewed 69 times
3. Script m-file: Plotting a Polynomial a. Create an m-file to plot a polynomial of any degree. • Ask the user to enter the coefficients of the polynomial as a row vector. For example, if the polynomial is: 3x3 - 7x+2 The user would enter: [3,0,-7,2] Make sure the instructions to the user on how to enter the polynomial coefficients are clear. Hint: In the past, some students have used a loop to enter the polynomial coefficients. This is not using MATLAB to the greatest advantage; entering the coefficients as a row vector does exactly the same thing (this is why MATLAB is called a high-level programming language). And, you do not need to ask the user the order of the polynomial and figure out how to create the loop Ask the user to enter the endpoints of the interval over which the polynomial is to be plotted, e.g.: Xmin and Xmeze- • Use the polyval command to evaluate the polynomial at 101 points (minimum) between and including Xmin and Xmar. The user should not have to enter the number of points (or increments). • Plot the polynomial. Make sure the plot has x- and y-labels, and a title. This can be done within the program b. Show your electronic file to the instructor for testing c. Print the completed m-file. A complete m-file includes your name and date in comment lines at the top of the m-file. Do not forget to use comment lines throughout the file to explain what key parts of the m-file are supposed to do.