Update README.md

Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
David Rotermund 2023-12-01 21:22:57 +01:00 committed by GitHub
parent 25c0def9b8
commit e8ce27f779
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,4 +13,61 @@ shows information regarding the sine function. Also a link to the detailed docum
Further useful commands include `quit` and `exit`, with which the Matlab session is terminated.
## Variables
Variables are introduced by assignment and do not have to be declared or defined. Names of the variables can be chosen freely. The only forbidden things are the use of special characters and digits at the beginning of the name. A distinction between uppercase and lowercase letters is not made. Examples:
| | |
| ------------- |:-------------:|
|`a = 3;`| 3 is assigned to a (no output)|
|`a`| result output|
|`b = -2.5` |-2,5 is assigned to b (with output)|
Note that Matlab uses a point to separate pre-decimal places and post-decimal places, following the conventions of the English language.
A major advantage of Matlab in comparison to a conventional programming language is the possibility to directly work with vectors. This concept shall only be touched briefly here, since it will be extensively treated in a separate chapter:
| | | |
| ------------- |:-------------:|:-------------:|
| `a = [3;1];` | defines a column vector | $\vec{a} = \left(\begin{array}{c}3\\1\\\end{array}\right)$ |
| `a(k)` | means the vector component | $a_k$ |
| `b = [0,3,-4];` | defines a row vector | $\vec{b} = (0,3,-4)$ |
The commas in square brackets can also be replaced by blank spaces.
Matlab cannot only calculate with vectors, but also with matrices. Thus, linear system of equations, such as
$x+2y = 3$
$3x+y = 1 $
can be formulated elegantly:
$\left(\begin{array}{cc}1 & 2\\3 & 1\\\end{array}\right) \left(\begin{array}{c}x\\y\\\end{array}\right) = \left(\begin{array}{c}3\\ 1\\\end{array}\right)$
respectively
$D\,\vec{x} = \vec{b} $
with the $2\times 2$ matrix
$ D = \left(\begin{array}{cc}1 & 2\\3 & 1\\\end{array}\right) \begin{array}{c}\leftarrow\;\;\mbox{1. line}\\\leftarrow\;\;\mbox{2. line}\\\end{array}$
$\nearrow$ $\nwarrow$
1. line 2. line
and the column vectors
$ \vec{x} = \left(\begin{array}{c}x\\y\\\end{array}\right) \quad\mbox{and}\quad \vec{b} = \left(\begin{array}{c}3\\ 1\\\end{array}\right) $.
Here, $\vec{x}$ is the solution vector being sought.
The formal solution of the equation $D\,\vec{x} = \vec{b}$ is given by
$\vec{x} = D^{-1}\, \vec{b} \, ,$
where $D^{-1}$ denotes the inverse of the matrix $D$.
Matrices are introduced in Matlab as the following