211 - Matlab Solver - NMO
211 - Matlab Solver - NMO
Code f = inline('xlogx-
1.2') root = fzero(f,2)
output: f = Inline
function: f(xlogx) =
xlogx-1.2 root =
1.2000
2) Simultaneous equations
Code
A=[1 -3 -1;2 -1 -9; 5 -1 -2];
B = [-30;5;142];
X = linsolve(A,B);
X = A\B
output:
X =
34.3097
19.8142
4.8673
3) Curve
fitting
Code
U = [0 1 2 3 4 5]; Z =[1
1.8 1.3 2 3.7 5.6];
plot(U,Z) output:
3] Numerical Integration
f=
Inline function:
>> I = quad(f,0.2,1.4)
I=
4.0509
4) Lagranges interpolation
Code
I = [0 2 3 6];
P = [648 704 729 729];
S = interp1(I,P,3,"spline")
output: S
=
729
5) Numerical integration
Code f =
inline('sin(x)');
Area = quad(f,0,3.141)
output:
Area =
2.0000
6) Ordinary differential equation
Code
f = inline('1-2*x*y');
[x,y] = ode23(f,[0 0.7],0)
output:
x = y =
0 0
0.0001 0.0001
0.0005 0.0005
0.0025 0.0025
0.0125 0.0125
0.0550 0.0549
0.1247 0.1234
0.1947 0.1898
0.2647 0.2527
0.3347 0.3108
0.4047 0.3633
0.4747 0.4094
0.5447 0.4487
0.6147 0.4809
0.6847 0.5060
0.7000 0.5105