MatLab:
The Language of Technical Computing
Solving linear equations:
3x+5y+21z = 33
7x+9y -11z = 4
8x -2y - z =
11
Matrix form:
A = 3 5
21
b = 33 X = x
7 9 -11
4
y
8 -2 -1
11
z
A*X = b =>
X = A-1 b = A \ b
Matlab command:
Polynomial Roots:
x3-2x-5
= 0
P(x) = 1* x3
+ 0* x2 -2* x -5
For what x, P(x) = 0 ?
Coefficients as elements of a vector: p = [ 1 0 -2 -5]
Roots: r = roots(p)
Matlab commands:
Algorithm Development: Calculate the average
of a data set
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
average=(1+2+3+4+5+6+7+8+9+10)/10
Matlab operations:
y=sum(x)/length(x) <= Calculate average
Self-designed Matlab function: