MatLab Assignment no.
1
1. Write the MATLAB code to plot the roots of a polynomial on the x-axis. Explain each
part of the code briefly.
2. Describe how hold on and hold off are used in MATLAB plotting with trigonometric
functions. Write a simple example to show how two different lines can be plotted on the
same graph. Also define the commands.
3. Explain the purpose of conv and deconv functions in MATLAB with respect to
polynomials. Give an example of each function.
4. Write a MATLAB script that:
Takes two polynomials, P ( x )=3 x2 +2 x +1 and Q ( x )=x 2−x+ 4 , and stores them as arrays.
Finds and displays the roots of each polynomial.
Finds and displays the product polynomial by using the conv function.
Calculates and displays the quotient and remainder of dividing P(x ) by Q(x ) using
deconv.
Include comments in your code to explain each step.
5. Write a MATLAB script that:
Prompts the user to input four numeric values in a single line.
Stores these values in an array and calculates the sum and product of all elements.
Plots the individual values, sum, and product on a single figure with different markers for
each (e.g., circles for individual values, a square for the sum, and a diamond for the
product).
Labels the x-axis as “Value Index” and the y-axis as “Values.”
Include comments for clarity and ensure the plot has a legend and grid lines.