0% found this document useful (0 votes)
15 views

211 - Matlab Solver - NMO

The document discusses several numerical analysis techniques including finding roots of equations, solving simultaneous equations, curve fitting, numerical integration, Lagrange interpolation, solving ordinary differential equations. Examples of code and output are provided for each technique.

Uploaded by

Abhishek Kasurde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

211 - Matlab Solver - NMO

The document discusses several numerical analysis techniques including finding roots of equations, solving simultaneous equations, curve fitting, numerical integration, Lagrange interpolation, solving ordinary differential equations. Examples of code and output are provided for each technique.

Uploaded by

Abhishek Kasurde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1) Find the roots of equation

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('sin(x)- log(x)+ exp(x)')

f=

Inline function:

f(x) = sin(x)- log(x)+ exp(x)

>> 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

You might also like