In matlab, a piecewise discontinuous function can be plotted using a for loop and an if/elseif/else statement.

X1 = []; X2 = []; X3 = [];
Y1 = []; Y2 = []; Y3 = [];
for x = linspace(-3, 5);
    if x <= 1
        y1 = x.^2;
        X1 = [X1, x];
        Y1 = [Y1, y1];
    elseif x <= 2
        y2 = x.^3 - 5;
        X2 = [X2, x];
        Y2 = [Y2, y2];
    else
        y3 = 5 - 2*x;
        X3 = [X3, x];
        Y3 = [Y3, y3];
    end
end  
plot(X1, Y1, X2, Y2, X3, Y3)
grid on

Plotting all three graphs in the same window results in a single graph that shows all three components of the piecewise function.

Discontinuous functions can be plotted using the plot function.

x = linspace(0, 2);
plot(x, 1./(x-1))

At the point of discontinuity, matlab generates a vertical line to demonstrate that the value at x = 1 goes to infinity.

A piecewise function with a discrete point can be plotted by plotting the components of the piecewise function as demonstrated above and plotting the discrete point as a single point in the same window.

X1 = []; X2 = []; X3 = [];
Y1 = []; Y2 = []; Y3 = [];

for x = linspace(0, 10);
    if x <= 2
        y1 = x.^2;
        X1 = [X1, x];
        Y1 = [Y1, y1];
    elseif x <= 4
        y2 = 4 - x;
        X2 = [X2, x];
        Y2 = [Y2, y2];
    else
        y3 = 2;
        X3 = [X3, x];
        Y3 = [Y3, y3];
    end
end
plot(X1, Y1, X2, Y2, X3, Y3, 2, 1, '*')

In matlab, graphs are plotted with the axes turned on as the default setting. If the axes are interfering with the graph, they can be turned off by using the axis off command.

 

Vertical and Horizontal Lines
Generating horizontal and vertical asymptotes can be done also using the plot function by setting one variable as a 1 x 2 matrix consisting of the value of the asymptote and the other variable as the range of the graph.
plot([-1,1], [2,2])
plot([2,2], [-1,1])                
Plot horizontal and vertical lines on top of other graphs by combining both equations together in the same plot function.
x = linspace(0, 2 * pi);
plot(x, cos(x), [0, 2 * pi], [0.75, 0.75])
xlim([0, 2 * pi])                
plot(x, sin(x), [pi/2, pi/2], [-1, 1])
xlim([0, 2 * pi])                
plot(x, sin(x), [pi/2, pi/2], [-1, 1], '--')
xlim([0, 2 * pi])                
Adding ‘--‘ after the pair of matrices commanding matlab to generate a horizontal or vertical line creates a dashed vertical or horizontal line.


                

Two n-by-n matrices A and B are called similar if there exists an invertible n-by-n matrix S such that
Theorem: If λ is an eigenvalue of a square matrix A, then its algebraic multiplicity is at least as large as its geometric multiplicity.    ▣
Let x1, x2, … , xr be all of the linearly independent eigenvectors associated to λ, so that λ has geometric multiplicity r. Let xr+1, xr+2, … , xn complete this list to a basis for ℜn, and let S be the n×n matrix whose columns are all these vectors xs, s = 1, 2, … , n. As usual, consider the product of two matrices AS. Because the first r columns of S are eigenvectors, we have
\[ {\bf A\,S} = \begin{bmatrix} \vdots & \vdots&& \vdots & \vdots&& \vdots \\ \lambda{\bf x}_1 & \lambda{\bf x}_2 & \cdots & \lambda{\bf x}_r & ?& \cdots & ? \\ \vdots & \vdots&& \vdots & \vdots&& \vdots \end{bmatrix} . \]
Now multiply out S-1AS. Matrix S is invertible because its columns are a basis for ℜn. We get that the first r columns of S-1AS are diagonal with &lambda's on the diagonal, but that the rest of the columns are indeterminable. Now S-1AS has the same characteristic polynomial as A. Indeed,
\[ \det \left( {\bf S}^{-1} {\bf AS} - \lambda\,{\bf I} \right) = \det \left( {\bf S}^{-1} {\bf AS} - {\bf S}^{-1} \lambda\,{\bf I}{\bf S} \right) = \det \left( {\bf S}^{-1} \left( {\bf A} - \lambda\,{\bf I} \right) {\bf S} \right) = \det \left( {\bf S}^{-1} \right) \det \left( {\bf A} - \lambda\,{\bf I} \right) \det \det \left( {\bf S} \right) = \det \left( {\bf A} - \lambda\,{\bf I} \right) \]
because the determinants of S and S-1 cancel. So the characteristic polynomials of A and S-1AS are the same. But since the first few columns of S-1AS has a factor of at least (x - λ)r, so the algebraic multiplicity is at least as large as the geometric.    ◂