Skip to main content

Section 7.4 Python/MATLAB recap

Vandermonde matrix. The \(n\times n\;\)Vandermonde matrix of a vector \(x=[x_1,\dots,x_n]\) is the matrix
\begin{equation*} \begin{pmatrix} 1&x_1&x_1^2&\dots&x_1^n\cr 1&x_2&x_2^2&\dots&x_2^n\cr \vdots&\vdots&\vdots&\ddots&\vdots\cr 1&x_n&x_n^2&\dots&x_n^n\cr \end{pmatrix}. \end{equation*}
In MATLAB, this matrix is created with the command vander(x). Notice that the matrix created by MATLAB switches rows with columns with respect to the standard definition above. One can get the standard matrix by using fliplr(vander(x)).

MATLAB/Python functions. So far we defined mathematical functions with the syntax like fun = @(x) x.^2-2. Often, though, one needs to use mathematical functions with a more complicated definition, that takes several lines of code, or even just define a set of instructions that accomplishes some task and is used several times in the same code. This can be accomplished with the syntax that we show in the several examples in the code below.
Graphics defaults. Many graphics parameters, such as the thickness of a graph, can be set directly within a plot command. Sometimes, though, we want to use the same option for several plots. In this case, rather than repeating the option over and over, one can set it once and for all within a given program. For instance, to set the thickness of graphs the command is set(groot,'defaultLineLineWidth',6.0).