Вы находитесь на странице: 1из 131

..

.. , ..

MATLAB

:
21.04.01 (131000)

, 2016


, -
-
.. .
,
, , -
, -
. , -
.
-
, MATLAB.
-
.
-
-
.

ISBN
c
.. , .. , 2016


, -
-
.. .
, -
-
, ,
, -
. , -
.
- , -
, , ,
. , -
-

.
. , -
,
MATLAB.
.
MATLAB, C# , -
, MS Excel? ,
.
Petrel ? -
, -
, -
, -
.


,
.

for i=1:10 -
(7);
~ (12);
~x, X
x, X (16);
i = m, n i m
n (56).

4
1.
MATLAB

1. MATLAB
MATLAB, -
The MathWorks, MATrix
LABoratory. MATLAB , -
. -
MATLAB . -
, -
,
(C++, Pascal .). MATLAB -
, ,
. ,
MATLAB, MS Excel, -
DLL , -
.

1.1. MATLAB. M-
,
4 (. 1.1).
,
Desktop Desktop Layout Default. -
MATLAB, .
, , Command
Window ( ), , -
Current Folder ( ), -
Workspace ( )
Command History (
). -
. ,
. , -
,
.

5
1. MATLAB

. 1.1. MATLAB

-
>>. , 2+2 Enter:
>> 2+2
ans = 4
ans , -
, - -
.
-
, , ,
, , -
.
.
MATLAB -
Editor,
-
(Notepad, WordPad ). *.m,
MATLAB M-le .

6
1. MATLAB

Editor
2 ( -
- ) File.
MATLAB,
, Dock Editor (
).
- :
clear all (Workspace),
;
clc (Command Window );
close all
( ).
MATLAB -
, , ^ ,
.
. 1.1 .
-
.

1.2. .
-
, Hello world! MATLAB
. -
,
.

. -
M-, :
clc; clear all; close all

U = 3*15 %
3 = U/2 %
C3 = 2^3 %
d = C3 - c3 %
sineOfPi = sin(3.14) %
MATLAB
.

7
1. MATLAB

% , , ..
, -
. ,
,
.
, -
MATLAB .
() () -
, C3 c3
, sin(3.14)
, sineOfPi ,
.

, . -
.
,
( , MATLAB)
. -
,
, (-
x, x, ~x ..), (
). . -
,
,
, ..

, .
,
:

, very_long_variable;
,
camelCase (), veryLongVariable.

-
,
. -
, . ,
:

8
1. MATLAB

clear all %
3 = U/2 % - U
U = 3*15
, -
( F5
Run).
- ,
, . -
, - .
,
,
, :
Change Directory , , -
;
Add to Path -
.
,
.
Workspace 5 -
(. 1.2).

. 1.2. MATLAB

9
1. MATLAB

. -
, -
;.
S = sin(3.14)
S =
0.0016

, 2- -
. MATLAB pi
15- . sin() :
S = sin(pi)
S =
1.2246e-016
.. S 16- -
. MATLAB (
) -
, .. , S = 1.2246 1016.

1.3.
-
. MATLAB . -
round(), -
. ,
. ,
:
n = 3;
x = round(pi*10^n)/10^n
.. 1000, ,
1000.
, -
. 1.1.

10
1. MATLAB

1.1. MATLAB


abs(x)
sqrt(x)
exp(x)
log(x)
log10(x)
( ) sin(x)
( ) cos(x)
( ) tan(x)
( ) cot(x)
asin(x)
acos(x)
atan(x)
round(x)
ceil(x)
floor(x)

1.4.
1. x y. , -
, .. x y, -
y x.
2 ax2 sin(x)
2. y = p x = 6, a = 3.
ea + ln(1 + x)

3. q = 3 e6.3 -
. 
4. w = 175 tg -
4
.
5. x. -
, .. , .
6. z. -
.

11
2.

2.
MATLAB , -
. -
11.
MATLAB , . -
, , , -
.
,
.
, ,
, . , -
>>,
.

2.1.
, , -
().
. , , -
, . -
.
, ~x.
() , .
, ,
, x1 , x2 xi .
,
.
-:
T~ = [23, 24, 22, 25, 26, 24, 25],
T1 = 23, T2 = 24, T3 = 22, T4 = 25, T5 = 26, T6 = 24, T7 = 25,
7.
MATLAB , -
,
. -
, ,
, .
MATLAB :
>> T = [23,24,22,25,26,24,25]

12
1. MATLAB

T =
23 24 22 25 26 24 25
. , -
:
>> T_weekend_mean = (T(6)+T(7))/2
T_weekend_mean =
24.5000
-
:
sum(T) ;
length(T) ( ) .
:
>> T_week_mean = sum(T)/length(T)
T_week_mean =
24.1429
,
. end:
>> T_Sunday1 = T(end)
T_Sunday1 =
25
>> T_Sunday2 = T(length(T))
T_Sunday2 =
25
, , .
-
(), .
:, -
, () -
. -. , ,
1 10:
>> odd = 1:2:10
odd =
1 3 5 7 9

13
2.

, 10
, odd.
:
>> inc = 0:0.2:1
inc =
0 0.2000 0.4000 0.6000 0.8000 1.0000
>> dec = 10:-1:1
dec =
10 9 8 7 6 5 4 3 2 1
1, :
>> x = 1:10
x =
1 2 3 4 5 6 7 8 9 10
, -
. , ,
, :
>> T_3_days = T([1 2 5])
T_3_days =
23 24 26;
-
(:), , -
, . , -
:
>> x_even = x(2:2:8)
x_even =
2 4 6 8
>> x_inverse = x(end-2:-1:1)
x_inverse =
8 7 6 5 4 3 2 1

2.2.
,
-,
-. ,
,
( ) , MATLAB. :

14
1. MATLAB

>> odd
ans =
1
3
5
7
9

: , , -
. MATLAB
:
() .. -
( ) ;
+ - - -
;
(.*), (./)
(.^); ..
, .
, 2 x:
>> x = x+2
x =
3 4 5 6 7 8 9 10 11 12
dec x:
>> s = dec+x
s =
13 13 13 13 13 13 13 13 13 13
, -
.*. -
-
, :
>> p = x.*dec
p =
30 36 40 42 42 40 36 30 22 12

15
2.

,
-
,
- - -
( -
).

x dec -
:
>> x*dec
ans =
330
,

:
>> dec2 = dec.^2
dec2 =
100 81 64 49 36 25 16 9 4 1
MATLAB
. ,
dec2
sqrt:
>> sq = sqrt(dec2)
sq =
10 9 8 7 6 5 4 3 2 1

2.3.
,
m n .
- -
. -
, X.
() , . -
, ,
. ,
, , Xij .

16
1. MATLAB

MATLAB , -
,
.
:
>> A = [1 2 3 4; 5 6 7 8; 9 10 11 12]
A =
1 2 3 4
5 6 7 8
9 10 11 12
( )
. , ,
3 2:
>> A(3,2)
ans =
10
(. . 2.1),
.
, -

. A,
, :
>> A(:, 1)
ans =
1
5
9
>> A(2, :)
ans =
5 6 7 8
,
, ,
;. ,
A :
>> y = [1; 2; 3];
>> B = [A y]

17
2.

B =
1 2 3 4 1
5 6 7 8 2
9 10 11 12 3

2.4.
- -
, A+c, , A*c. -
A B , -
A+B. (
), *
(
). , - x -
A x.
>> x = [2 4 6 8]
x =
2
4
6
8
>> y = A*x
y =
60
140
240
, , -
, , . ,
A B , -
C=A.*B C, -

A B.
-
det(A).
,
:
zeros(m,n) m n ,
;

18
1. MATLAB

ones(m,n) m n ,
.
:
>> A = ones(2,3)
A =
1 1 1
1 1 1
>> B = zeros(4,1)
B =
0
0
0
0
, -
,
, -
1.
, -
, .
-
. -
,
.
size() .
(
, ), ,
:
>> d = size(A)
d =
2 3
>> [m, n] = size(B)
m =
4
n =
1

19
2.

2.5.
M S Excel
(, data.xls) -

N = xlsread(data.xls);
N ,
.
, ,
N = xlsread(data.m, 2, A3:D16).
,
xlswrite().

.
M S Excel.
MATLAB xls-. -
, mat- (-
MATLAB), -
load() save().

2.6.
MATLAB.

1. ~x = [1, 2, , 97].
2
(x1 x3 x4 )x2 .
2. ~x. ~y, -
, .
3. .
, , .
4. ~x
2, 5, 8, ..., 20. :

~ y , yi = x2i , i -
;
~x -
~y .

20
1. MATLAB

5. n- A B -
A1 , A2 , ..., An s
B1 , B2 , ..., Bn .
P
n
=
2
(Ai Bi ) ,
i=1
.
6. , -
xi yi
zi = , xi , yi ~x = [1, 2, 3, 4]
xi + yi
y = [8, 6, 4, 2].
~
7. x n.
n n, x.
8.

1 2 3 4 5

A= 7 9 1 0 1 .

8.3 0 7 1 1
:
A A;
CC 2BC + BB , B
A, ,
; C A,
, ;

A.
9. :
P
3
Ai1 Ai2 ;
i=1
P
5
Aik Ajk , i, j = 1, 3,
k=1

A .

21
3.

3.
3.1. plot()
M-
F5 Run, -
,
. , -
( clear all
clc).

plot(), :
x ;
y .
x,y . -
.
3.1. y = ax2 + bx+ c.
,
, ,
plot():

x = -2:0.1:2;
a = 3; b = 5; c = 2;
y = a*x.^2+b*x+c;
plot(x,y)
,
,
.
, , x y,
,
.
x
!

22
1. MATLAB

25

20

15

10

5
2 1.5 1 0.5 0 0.5 1 1.5 2

. 3.1.

3.2.
plot. -
() , -
(. 3.1)
(. 3.2); , (. 3.3) .
, r:
.
-
. , , -
, , plot(x,y,LineWidth,2)
2 . -
.
, , -
.
( MarkerSize),
( MarkerEdgeColor) (
MarkerFaceColor).

23
3.

3.1.

y
m
c
r
g
b
w
k

3.2.

-
--
:
-. -

3.3.

o
x
+
*
s
d
p

24
1. MATLAB

, -
:
title ( ) ;
text (x,y, ) -
(x, y);
gtext () ,
;
xlabel( x) ylabel( y)
;
legend() -
.

( FontName), ( FontSize), -
( FontAngle italic),
( FontWeight). -
, -
. 3.2.
,
plot() , -
, -
-
hold on.
3.2.
, . -
, -
. -
grid on (. 3.2).

x = -2:0.1:2;
a = 3; b = 5; c = 2;
y = a*x.^2+b*x+c;

D = b^2-4*a*c; %
%
x12 = [(-b+sqrt(D))/(2*a), (-b-sqrt(D))/(2*a)];

plot(x, y, LineWidth, 2)
grid on; hold on

25
3.

plot(x12, [0 0], d, MarkerEdgeColor, b,...


MarkerFaceColor, m,...
MarkerSize, 10)

title(Graph 2, FontSize, 16, FontName, Times)


xlabel(x, FontSize, 16, FontWeight, bold)
ylabel(Function, FontSize, 16, FontWeight, bold)

text (-1.1, 3, Solution,...


FontAngle, italic, FontSize,13)
legend (parabola, roots)

, -
figure .
,
.

Graph 2
25
parabola
roots
20

15
y

10

solution
0

5
2 1.5 1 0.5 0 0.5 1 1.5 2
x
. 3.2.

26
1. MATLAB

3.3.

,
. - -
, -
. ,
, .. .
f igure,
axes. ,
set(h, property, value), h , property
, value . ,
.. , -
gca (GetCurrentAxes).
, Oy ,
, YDir. -
reverse set(gca,YDir,reverse).


- x1, y1 x2, y2
, ,
y1(i) < y2(i) i. .
fill(). -
, -
, .
x1, y1
Ox, -
x2, y2. , x2, y2
: x2(end:-1:1) y2(end:-1:1) (. 4 . 2.6). -

:
fill([x1, x2(end:-1:1)], [y1, y2(end:-1:1)], color)
color , -
, ( r -
), 0 1, -
, (RGB),
[0.5 0.25 0.1] .

27
3.


F igure ()
Insert () . -
, Arrow ()
, -
. , -
P ropertyEditor ( ). -
, ,
, P ropertyEditor ( ).
,
F igure () F ile Save. -
(bmp, jpg,
png, tif, eps, pdf .).

3.4.
1. y = x sin(x) [2 , 2 ].
2. y = 1 + x2
y = 1 x2 .
. . -
.
3. .
!
4.
.

28
1. MATLAB

4. 3D
4.1.
, -

~r(s) = [x(s), y(s), z(s)],

x, y, z,
plot3(x, y, z). ,
, ,
, .
, LineWidth, MarkerSize . (. . 3.2).

4.2.
Z z(x, y)
(Xi , Yj ), .. Zij = z(Xi , Yj ). -
. plot3()
, , .. -
, ,
, Z.
ndgrid(), ,
:
[Xgrid, Ygrid] = ndgrid(X, Y);
( , -
): X (n ) Y (m ). 2 -
n m.
, X = [1 2 3], Y = [5 6], -
Xgrid Ygrid
Xgrid = Ygrid =
1 1 5 6
2 2 5 6
3 3 5 6
:
plot3(Xgrid, Ygrid, Z, .k, MarkerSize, 5);

29
4. 3D

4.3.
MATLAB
: mesh() surf().
() , -
. -
x y (
ndgrid()), z -
. .. X, Y, Z mesh() surf()
. -
.
. 4.1 z = x2 y 2 , -
mesh(). ,
0.2.

[X, Y] = ndgrid(-2:0.2:2, -2:0.2:2);


Z = X.*2 - Y.*2;
mesh(X, Y, Z);
title (3D plot with function mesh);
xlabel(x); ylabel(y); zlabel(z);

3D plot with function mesh

0
z

4
2
1 2
0 1
0
1 1
y 2 2
x

. 4.1. , mesh()

surf() -
,
z(x, y) , .
. . 4.2 ,

30
1. MATLAB

surf(). -
, -
( colorbar).

3D plot with functions surf and colorbar


4

3
4
2
2
1

0
z

2
1

4 2
2
1 2
1 3
0
0
1 1 4
y 2 2 x

. 4.2. , surf ()

(0.1 0.2),
(. 4.3).

3D plot with dense grid

0
z

4
2
1 2
0 1
0
1 1
y 2 2
x

. 4.3. , surf (),

31
4. 3D

4.4.

z = f (x, y) , .. ,
. -
MATLAB contour()
contourf(). (. 4.4),
(. 4.5). -
, contour() contourf(),
ndgrid().
contour(X, Y, Z,10) contour(X, Y, Z,20)
2 2

1.5 1.5

1 1

0.5 0.5

0 0

0.5 0.5

1 1

1.5 1.5

2 2
2 1 0 1 2 2 1 0 1 2

. 4.4. , -
contour(),

contourf(X, Y, Z,10) contourf(X, Y, Z,20)


2 2

1.5 1.5

1 1

0.5 0.5

0 0

0.5 0.5

1 1

1.5 1.5

2 2
2 1 0 1 2 2 1 0 1 2

. 4.5. , -
contourf (),

32
1. MATLAB


z(x, y) (. 4.6):
[C,h] = contour(X, Y, Z, 10);
clabel(C,h);

contour(X, Y, Z,10) with labels


2
2.
1 545 3.2727 2
0. .09 5 818 64
36 09
2.545
5 1. 63 4
36 9 0.3 636 09
1.

1.5 9 0 3 09
09 1. .545 3.2727

4 1.8182 . 0 .
1 0 1.
09 818 5

45 2
0 1.0909

2.5 818
.36
2

5
1 36

1.
2

4 64
363
0.

27
0.3

64
0.5

63

3.27
63

1.0909
1.0909

0.3
64

0
82

1.81
1.81

0.5

2.5
455

82
0.

455
363
2.5

0.
3 64 36
4 64 36
6 36
1 36 0.3 1.0909
0. 4

1.
09

09
09

1.8182 1

09
.09
1.

1.5 09 0.
2.54 36
09 55 1
.81 36
.09 455 82 4
1 2.5 3.2727
2
2 1.5 1 0.5 0 0.5 1 1.5 2

. 4.6. -

clabel(C,h)
, . ,

clabel(C, h, FontSize,15, Color,r, LabelSpacing,72);


15 , -
72 , 1
(2.54 ). clabel(C, manual),
.

33
5.

5.
5.1. f or
,
.
for:
for i = i1:h:i2
<>
end
i , ,
i1 , ; h
, ( ,
1); i2 , -
.
for
end. , , .
i , ..
, i1, h i2 , -
, 1, ..
i = i1:i2.
, ,
.
5.1. 1 10.
S 0.
S 1, 2, 3
.. , ,
S. i
.
S=0;
for i=1:10
S = S+i;
end
S
. S = S+i,
. ,

34
1. MATLAB

= , -
== (. . 5.1), ,
.. , ,
, . :
S 0;
(i = 1) S + i = 0 + 1 = 1 -
S, S = 1;
(i = 2) S + i = 1 + 1 = 2 -
S, S = 2 ..
-
, -
.
, -
S.
(Editor) for end
.
.
-
. break.
if.
break ,
,
.

5.2. if

if <_()>
<>
end
if (), MATLAB
. ( -
), ,
end, , -
, end.

35
5.

if -
:
if _
<1>
else
<2>
end

elseif. , -
, else -
if.
5.2. ,
, a, b, c.

,
if. , -
2 ; ,
; , -
-
. -
, error().
clear all
clc

a = 3; % x^2
b = 5; % x
c = 2; %
D = b^2-4*a*c; %

if D > 0 % 2
x(1) = (-b+sqrt(D))/(2*a)
x(2) = (-b-sqrt(D))/(2*a)
elseif D == 0
x = -b/(2*a) % 1
else
error( ) %
end

36
1. MATLAB

- . -
, ,
. MATLAB
%. . -
%
. .
-
. , -
-
.

(. 5.1) (. 5.2).
5.1.

==
~=
<
>
<=
>=

5.2.

~
||
&&

5.3. -

(, -
).
--. -
function.

37
5.

,
myfunc. , myf unc.m.
myfunc, -
X1, X2, ..., Xn
Y1, Y2, ..., Ym . -
, .
myf unc.m .

function [Y1, Y2, ..., Ym] = myfunc(X1, X2, ..., Xn)
, -
.
5.3.
. solveSquareEq.m
:
%
function [x1, x2] = solveSquareEq(a, b, c)
D = b^2-4*a*c;
if D > 0
% 2
x1 = (-b+sqrt(D))/(2*a);
x2 = (-b-sqrt(D))/(2*a);
elseif D == 0
x1 = -b/(2*a); % 1
x2 = NaN;
else
error( ) %
end
, x2 -
N aN (N ot a N umber), ,
.
, -
clear all,
, . -
clc,
. -
, , , ..

.

38
1. MATLAB


, -. , -
-
, .
, - ()
.
.
, x1 x2:
a = 4;
coeff2 = -2;
[x1, x2] = solveSquareEq(b, coeff2, 0.5+0.5);
-
, ,
. , -
-
. ,
, -
.

. ,
,
, -
.
%
function x = solveSquareEq2(a)
D = a(2)^2-4*a(1)*a(3);
if D > 0
% 2
x(1) = (-a(2)+sqrt(D))/(2*a(1));
x(2) = (-a(2)-sqrt(D))/(2*a(1));
elseif D == 0
x(1) = -a(2)/(2*a(1)); % 1
x(2) = NaN;
else
error( ) %
end
solveSquareEq2 :

39
5.

p = [4, -2, 1];


x = solveSquareEq2(p)
, -
- , :
??? Input argument "a" is undefined
Error in ==> solveSquareEq2 at 2
, -
. -
-,
.


, ,
, . -
. ,
-
, -
.
, (-
, a = 2.5;) ( )
, .
,
, . -
, -
. -
,
.

5.4.
1. 1 + 3 + 4 + ... + 18.
2. n.
n! = 1 2 3 ... n.
3. n. , -

1 + 1 2 + 1 2 3 + 1 2 3 4 + ... + 1 2 ... n.
n = 4, n = 6 n = 17.

40
1. MATLAB

P
n
4. (ai + 1)2 , ~a = [0, 2, 4, ..., 2(n 1)].
i=1
n, -
n.
Q
10 
5. bk k2 ,
k=1
 
~b = 1 , 1 , 1 , ..., 1 .
30 28 26 2

6. ~x xm = 2m 1,
m = 1, 9.
7. Q Qij = i2 + j 2 ,
i, j = 1, 5.
8. a, b, c n. -
, n n,
b, c
a. .
9. . ,
.
10. . ,
, 5. ,
.
Qn
11. , (10 Xk ),
k=1
k6=2,k6=4
~ = [X1 , X2 , ..., Xn ]. 3- -
X
~ X
X, ~ = [1, 2, 1, 2, 0, 1, 2].

41
2.

6.
6.1.
-
. , -
-
.
, , -
,
.

.
x , x -
. .
6.1. x -
x = x x .
, x = x + x.
6.2.
x |x x |.
x , x . ,
x x, -
, .. x,
|x x |. ...
6.3. () -
x x, ,
|x x | x.
-
.
-
, -
-
.

42
2.


2 ,
,
2 .
6.4.
x
x x = .
|x |
, .
6.5. ()
x x, -
, | x| x.
6.1. -
, | x| << |x |, -
-

x
x .
|x|
. x = x + x, x = x x, -
,
x x 0
x = = = .
|x | |x x| 1 0
-
x
|x| 0 = . | x| << |x |
|x|
x x , |0 | << 1, ,
. :

x(1 0 ) = 0 ;
x x0 = 0 ;
x = 0 + 0 x.

0 x,
| x| x
| x| |0 | = .
|x| |x|
x
, x , .
|x|

43
6.

-
-
.
.

6.2.
6.2.1.
a b -
a b. ,
x = a + b.
,

a = a + a; b = b + b; x = x + x; x = a + b .

|x x | = |a + b a b | |a a | + |b b | a + b,

..
(a + b) = a + b. (6.1)
, -
:

|x + y| |x| + |y|

x y.
x = a b:

|x x | = |a b (a b )| |a a | + |b b | a + b,

.. :

(a b) = a + b. (6.2)

6.2.2.
:

x = a b = (a + a)(b + b) = a b + b a + a b + a b =
= x + b a + a b + a b,

44
2.

x = a b .
| a| << |a|, | b| << |b|, a b
, .. | a b| << |b a + a b|. -
:
|xx | = |b a+a b+ a b| |b a+a b| |b a|+|a b|.
x = a b

|x x | a b

| x| = + a + b.
|x | a b
, -

(ab) = a + b. (6.3)
| a| << |a|, | b| << |b|,
.. a << 1, b << 1.
a < 0.1, b < 0.1.
, -
1
x = . :
a

1 1 a a

|x x | = = ;
a a aa
|x x | |a a | a
x = = |a | = a.
|x |
|a||a | |a|
.. ,
x = a.
:  
a 1
= a + = a + b. (6.4)
b b

6.2.3.
f (a).
, a
x = f (a), f () . ,
, a = a + a, a << a ; x = f (a ).
f (a ) a:
f (a ) f (a) + f (a)(a a).

45
6.

|x x | = |f (a) f (a )| |f (a) f (a) f (a)(a a)| =


= |f (a)||a a| |f (a)|a,

|f (a)|a d
f (a) = = ln f (a) a. (6.5)
|f (a)| da

f (a) = ak

d 1
(ak ) = k ln a a = |k| a = |k| a. (6.6)
da a

-
1
,
2
 1
a = a.
2
-
. x = f (a, b, c), a = a + a,
b = b + b c = c + c.
a, b c, x.
f () :

f f f
f (a , b , c ) f (a, b, c) + (a a) + (b b) + (c c).
a b c
:

|x x | = |f (a, b, c) f (a , b , c )|

f
(a a) + f (b b) + f (c c)
a b c

f
a + f b + f c, (6.7)
a b c
 
1 f f f
f (a, b, c) = f (a, b, c) a a + b b + c c =


ln f
= a + ln f b + ln f c. (6.8)
a b c

46
2.

6.3.
, , ,
, 17 23 41 12
3 .
, (
, , ,
). , -
16
, . -

.
-
, , 5, . -
, , ,
. -
, -
. , -
, .
6.1. x :

x = 4.8932767409283409;
x = 0.0007389086398353;
x = 0.0001510048744341.

-
, x = 0.02%. , x = 0.001. 7 > 5,
, .
, -
, x = 4.893.

, -
. -
, , -
5 .
, -
.
5 .

47
6.

6.2.

2.654x2 4.875x + 0.0375 = 0.

,
. a, b c,
:

a = 2.654, a = 0.0005;
b = 4.875, b = 0.0005;
c = 0.0375, c = 0.00005.

:
a
a = = 0.0001883948757;
|a|
b
b = = 0.0001025641026;
|b|
c
c = = 0.001333333333.
|c|
,

b D
x1,2 = , D = b2 4ac.
2a
-
:

y1 = b2 = 23.765625;
y1 = 2b = 0.0002051282052;
y1 = y1 |y1 | = 0.004875000002.

y2 = 4ac = 0.3981000;
y2 = a + c = 0.001521728209;
y2 = y2 |y2 | = 0.0006058000000.

48
2.

D = b2 4ac = 23.3675250;
D = y1 + y2 = 0.005480800002;
D
D = = 0.0002345477325.
|D|


y3 = D = 4.833996794;
1
y3 = D = 0.0001172738663;
2
y3 = y3 |y3 | = 0.0005669014937.

y4 = b + y3 = 9.708996794;
y4 = b + y3 = 0.001066901494;
y4
y4 = = 0.0001098879232.
|y4 |

y4
x1 = = 1.829125244;
2a
x1 = y4 + a = 0.0002982827989;
x1 = x1 |x1 | = 0.0005455965973.

y5 = b y3 = 0.041003206;
y5 = b + y3 = 0.001066901494;
y5
y5 = = 0.02601995303.
|y5 |

y5
x2 = = 0.007724793895;
2a
x2 = y5 + a = 0.02620834791;
x2 = x2 |x2 | = 0.0002024540859.

49
6.

:
x1 0.03%;
x1 0.0005;
x1 1.829.

x2 3%;
x2 0.0002;
x2 0.0077.

, -
.
(6.7) (6.8) -
.

b + D
f (a, b, c) = , D = b2 4ac.
2a
:

f 2 ac + b D D
= = 0.6921186130;
a 2a2 D

f b + D
= = 0.3783877653;
b 2a D
f 1
= = 0.2068681554.
c D


f f f
x1 = a + b + c = 0.0005455965970;

a b c
x1
x = = 0.02982827987.
|x1 |
:
x1 0.0005;
x1 0.03%;
x1 1.829.

50
2.

6.4. :

. -
, , -
-
.
-

S ()-
h,
kp -
kn . :
Sh ( );
Shkp ;
Shkp kn -,
.
-,
, .
, -
,
, . -
( ) -

V = Shkp kn .

V
, ,
,
Q = Shkp kn . (6.9)


.

51
6.

,
, .

: r1 = 2
r1 = 2 r2 = 3 (. 6.1).

2.5

1.5

0.5
Y, km

0.5

1.5

2.5
2 1 0 1 2 3
X, km

. 6.1.

r1 1%,
r2 0.5%.
(6.9) -
(. 6.1),
, -
Q.

6.1.
.
h, 12.4 0.3
kp 0.22 0.02
kn 0.72 0.08
0.955 0.005
, / 3
841.4 0.5

52
2.

6.5.
1. . 6.4 Q (6.9),
, -
(6.1) (6.6).
.
2. , -
(6.7) (6.8).

. Sel = r1 r2 .

53
7. .

7. .
7.1. -

Yi = f (Xi ) n -
~ = [X1 , X2 , ..., Xn ] . X
X ~ Y
~ .
y(x), f (x), ,
Xi :
y(Xi ) = Yi . (7.1)
, Xi
.

y 10


8

6
0 2 4 6 8 10
x

. 7.1.

-
, Xi Yi , -
, x y.

54
2.

-
.

, .
7.1. n (Xi , Yi ) -
n 1.
,
1- , -
.
. :
n
X
y(x) = pi xi1 , (7.2)
i=1

pi n .
, n :

Pn

y(X1 ) = pi X1i1 = Y1 ;

i=1

Pn

y(X2 ) = pi X2i1 = Y2 ;
i=1





P
n


y(Xn ) = pi Xni1 = Yn .
i=1

, n n p1 , ..., pn . -
:

1 X1 X12 ... X1n1 p1 Y1

1 X X22 ... X2n1 p2 Y2
2
.. .. = .. . (7.3)
. . .

1 Xn Xn2 ... Xnn1 pn Yn
X, p~,
Y~ , X~p=Y ~.
,
Q X
, det(X) = (Xj Xi ), -
i<j
Xi = Xj , i 6= j.

55
7. .

,
, ,
.
n (Xi , Yi ) -
pi , , y(x)
(7.2).
.

7.2.
(7.3) , X
, .. X -
~ -
Y
~p.
, -
. (2 ), , ,
(3 I- II- -

), . . -
.

n
Y
li (x) = (x Xk ), i = 1, n,
k=1
k6=i

.. i 1 n.
Xr , r 6= i,
li (Xr ) = 0.
Xi ,
n
Y
li (Xi ) = (Xi Xk ) 6= 0.
k=1
k6=i


li (x) pi :
n
X
y(x) = pi li (x).
i=1

56
2.

.
pi ,
(7.1):

Pn

y(X1 ) = pi li (X1 ) = Y1 ,

i=1


y(X2 ) = P pi li (X2 ) = Y2 ,
n

i=1





P
n


y(Xn ) = pi li (Xn ) = Yn .
i=1

li (Xr ) = 0 r 6= i,


p1 l1 (X1 ) = Y1 ,



p2 l2 (X2 ) = Y2 ,





pn ln (Xn ) = Yn .

Yi
, pi = . -
li (Xi )
,
Xn Xn n
Y
Yi x Xk
y(x) = li (x) = Yi . (7.4)
l (Y )
i=1 i i i=1
Xi Xk
k=1
k6=i

.

n
Y x Xk
ai (x) = (7.5)
Xi Xk
k=1
k6=i

ai (x) -, ~a(x) = [a1 (x), a2 (x), ..., an (x)] .


(7.4)
:
~.
y(x) = ~a (x)Y (7.6)

57
7. .

7.3. MATLAB
-
-
. : -
(. . 5.3), (,
), (. . 1.1),
(. . 2.5) .
-
, , -
. -
, , -
.
-
. -
, .
, -
, ,
. ,
(7.5), ( ) -
.
-
. ,
..
. ,
,
, , ,
: , .
MATLAB :
(), -
()
. -
% (. . 1.2). , -
.
, -
. -
, .
, ( -
) -
.

58
2.

, .

: , -
, . , -
n = 6
, n = 8.
6 -
length() (. . 2.1) .
, -
. myfunk1()
zadacha2() , -
, ,
, .
.
(.. ) -
: . ,
-
.

(7.4)(7.6) , x
.
-
, ,
, x
,
. MATLAB:
,
(. . 2.2).
-
:
, -
;

, (. . 2.2).
, -
, , , -
, , .

59
7. .

7.4.
www.amcm.gubkin.ru,
AppendixA.xls.

1. -

1 (. A.1). L = 13 .
() .
2. (7.5)(7.6) , -
x .
3. 0.5 (. A.2).
L = 20 . -
.

60
2.

8. -

-
. ,
, Xi
Yi , i = 1, n. :

Xi+1 Xi = h = const .

:
x X1
t= .
h

Xi X1 X1 + (i 1)h X1 (i 1)h
Ti = = = = i 1.
h h h

8.1.
, -
. m- m Yi
Yi , m = 0, n 1, -
:

0 Yi = Yi , i = 1, n, (8.1)
Yi
m
= m1
Yi+1 m1
Yi , i = 1, n m. (8.2)

1 Yi Yi = 0 Yi+1 0 Yi = Yi+1 Yi , i = 1, n 1,
2 Yi = 1 Yi+1 1 Yi , i = 1, n 2,

n1
Yi = n2 Yi+1 n2 Yi , i = 1.

, n m
m- .

61
8.


. , n = 5 :

0 Y 1 Y 2 Y 3 Y 4 Y
Y1 Y2 Y1 1 Y2 1 Y1 2 Y2 2 Y1 3 Y2 3 Y1
Y2 Y3 Y2 1 Y3 1 Y2 2 Y3 2 Y2
Y3 Y4 Y3 1 Y4 1 Y3
Y4 Y5 Y4
Y5

-
,
m (aYi + bZi ) = a m Yi + b m Zi , (8.3)
Zi , i = 1, n m.

8.2.
:
p1 (t) = 1,
pk (t) = pk1 (t)(t (k 2)), k = 2, n.

..
p2 (t) = t, p3 (t) = t(t 1),
p4 (t) = t(t 1)(t 2),

n2
Y
pn (t) = (t j).
j=0

Ti = i 1

p1 (Ti ) = 1, p2 (Ti ) = i 1,
p3 (Ti ) = (i 1)(i 2),

62
2.

p4 (Ti ) = (i 1)(i 2)(i 3),


...
pi2 (Ti ) = (i 1)(i 2)...(i 1 (i 2 2)) = (i 1)(i 2) ... 3,
pi1 (Ti ) = (i 1)(i 2)...(i 1 (i 1 2)) = (i 1)!,
pi (Ti ) = (i 1)(i 2)...(i 1 (i 2)) = (i 1)!,
pi+1 (Ti ) = pi+2 (Ti ) = ... = pn (Ti ) = 0.
: pk (Ti ) = 0 k > i, k i

(i 1)!
pk (Ti ) = .
(i k)!
-
,

(i 1)! , k i
pk (Ti ) =
0 (i k)! .

0, k>i
, i = 1
(
(1 1)! , k 1
1, k = 1
pk (T1 ) =
0 (1 k)! = .
0, k =
6 1
0, k>1
-
:
pk (Ti ) = 0 pk (Ti+1 ) 0 pk (Ti ) =

i! (i 1)! , k i
, k i+1
= (i + 1 k)! (i k)! =

0, k >i+1 0, k>i
 
(i 1)! i

(i k)! i + 1 k 1 , k i

= =

i! 0, k =i+1


0, k >i+1

(i 1)!(k 1) , k i + 1
= (i + 1 k)! .

0, k >i+1

63
8.

k = i + 1 ,
k i, .
i = 1

(
0!(k 1)
0, k = 1
, k2 1, k = 2
pk (T1 ) = (2 k)! = 1, k = 2 = .

0, k =
6 2
0, k>2
0, k > 2

2 pk (Ti ) = pk (Ti+1 ) pk (Ti ) =



i!(k 1) , k i + 2 (i 1)!(k 1) , k i + 1
= (i + 2 k)! (i + 1 k)! =

0, k >i+2 0, k >i+1
 
(i 1)!(k 1) i

1 , k i+1
(i + 1 k)! i+2k
= =

(i + 1)! 0, k =i+2


0, k >i+2

(i 1)!(k 1)(k 2) , k i + 2
= (i + 2 k)! .

0, k >i+2

, , k = i + 2
k i + 1 , -
.
i = 1

0!(k 1)(k 2) , 0, k2

k3

2!, k=3

pk (T1 ) =
2 (3 k)! = 2!, k=3 = .

0, k>3

0, k 6= 3
0, k>3

,
:

i!(k 1)(k 2) ,

k i+3
3 pk (Ti ) = 2 pk (Ti+1 ) 2 pk (Ti ) = (i + 3 k)!

0, k >i+3

64
2.

(i 1)!(k 1)(k 2) , k i + 2

(i + 2 k)! =

0, k >i+2
 
(i 1)!(k 1)(k 2) i


1 , k i+2

(i + 2 k)! i+3k
= =

(i + 2)! 0, k =i+3

0, k >i+3

(i 1)!(k 1)(k 2)(k 3) ,



k i+3
= (i + 3 k)! .

0, k >i+3

i = 1

0!(k 1)(k 2)(k 3) , 0, k3

k4

3 pk (T1 ) = (4 k)! = 3!, k=4 =

0, k>4

0, k>3

3!, k = 4

= .
0, k 6= 4

, m 1
m-

(i 1)!(k 1)(k 2)...(k m) , k i + m
pk (Ti ) =
m (i + m k)! .

0, k >i+m
, i = 1

0!(k 1)(k 2)...(k m) , k m+1
pk (T1 ) =
m (1 + m k)! =

0, k >m+1


(
0, k m
m!, k =m+1
= m!, k = m + 1 = .

0, k 6= m + 1

0, k > m + 1
-
, 0! = 1, -

65
8.

:
(
m!, k = m + 1
m pk (T1 ) = , m = 0, n 1, k = 1, n. (8.4)
0, k 6= m + 1

8.3.
-
:
n
X
y(t) = ak pk (t).
k=1
-
, y(Ti ) = Yi , , ,
, i = 1 m y(T1 ) = m Y1 .
,
n
X
m y(T1 ) = ak m pk (T1 ) = am+1 m pm+1 (T1 ),
k=1

k = m + 1 .
,
m y(T1 ) = am+1 m pm+1 (T1 ) = am+1 m! = m Y1 .
:
m Y1
am+1 =.
m!
-
: n
X k1 Y1
y(t) = pk (t), (8.5)
(k 1)!
k=1

p1 (t) = 1, (8.6)
pk (t) = pk1 (t)(t (k 2)). (8.7)

8.4.
. 7.4,
.

66
3.

9.
9.1.
, -
.
, ,
, -
- , ..
(. 9.1).

y
8

8
0 1 2 3 4 5 6 7 8 9 10
x

. 9.1. 60-

, y(x) = e25x ,
, , -
.

67
9.

(. 9.2).

y
1

5
5 4 3 2 1 0 1 2 3 4 5
x

. 9.2. 17-

, -
( ) .
X1 , X2 , ..., Xn :
Xi+1 Xi = h = const, i = 1, n 1.
(. 9.3):


P1 (x), X1 x < X2 ,




P (x), X2 x < X3 ,
2
y(x) = (9.1)







Pn1 (x), Xn1 x Xn .
Xi -
Yi (9.1) . -

68
3.

, -
y(x) . -

(.. )
.
9.1. - ,
-
, .
replacements
, , -
, ,
.
,
..
y
P4 (x) P5 (x)

P1 (x)
P2 (x)

P3 (x)



P6 (x)

1 2 3

. 9.3.

9.2.
,
x X1
, t = . -
h

Xi X1 X1 + (i 1)h X1 (i 1)h
Ti = = = = i 1.
h h h
.. 0, 1, 2, ..., n 1.

69
9.

[Ti , Ti+1 ] 2-
:

Pi (t) = ai + bi (t i + 1) + ci (t i + 1)(t i), i = 1, n 1. (9.2)

Pi (Ti ) = Pi (i 1) = ai = Yi . (9.3)
Pi (Ti+1 ) = Pi (i) = ai + bi = Yi+1 , (9.4)

(9.3) (9.4) , , Yi+1 Yi = Yi


1- ,

bi = Yi . (9.5)

:
dPi
= bi + (2 t 2i + 1) ci .
dt
i + 1 i,
dPi+1
= bi+1 + (2 t 2i 1) ci+1 .
dt
1- -
:
dPi dPi+1
(ti+1 ) = (ti+1 ), ..
dt dt
b i + ci = bi+1 ci+1 ,
i = 1, n 2.

(9.5), -
bi bi+1 . Yi+1 Yi = 2 Yi
,
ci+1 = ci + 2 Yi . (9.6)
, ai , bi i.
ci i > 1. c1
,
:
d2 Pi
= 2 ci .
dt2

70
3.

, , -
d2 P
1
, (t1 ) = 0, .. c1 = 0. -
dt2
,
(, ).
d2 P
1 2d2 P
2- , (t2 ) = (t2 ),
dt2 dt2
.. c1 = c2 . (9.6) i = 1
1 2
c1 = Y1 .
2
. -

. -
3 ,
. , P1 (t) ,
P2 (t) X1 x X3 .

9.3.
,
(9.2):

ai = Yi , i = 1, n 1, (9.7)
bi = Yi , i = 1, n 1, (9.8)
1 2
c1 = Y1 , (9.9)
2
ci+1 = ci + 2 Yi , i = 1, n 2. (9.10)

y(x) x [X1 , Xn ]
i, ( -
, Pi (x)). -
x X1
t = .
h
, , t = 2.34. , t
Ti = 2 Ti+1 = 3, i 1 = 2, .. i = 2 + 1 = 3.
t 1,
i = [t] + 1.
t [0, n 1), t = n 1
i = n, Pn (t)
.

71
9.

(t = n1)
Pn1 (t).

i = min ([t] + 1, n 1) .

i ai , bi , ci , -
t (9.2) y(x).

9.4.
www.amcm.gubkin.ru,
AppendixA.xls.

1. (. A.3)
100 , .
L = 1500 .
2. , .
.
3. -
, Xi+1 Xi = hi .
.

Pi (x) = ai + bi (x Xi ) + ci (x Xi )2 .

72
3.

10.
10.1.
, -
, -
:
Pi (t) = ai + bi (t i + 1) + ci(t i + 1)(t i) + di(t i + 1)(t i)(t i 1).
:
Pi (Ti ) = ai = Yi , (10.1)
Pi (Ti+1 ) = ai + bi = Yi+1 . (10.2)
(10.1) (10.2),
bi = Yi+1 Yi = Yi . (10.3)
:
dPi
= bi + ci (2 t 2 i + 1) + di (3 t2 6 i t + 3 i2 1),
dt
d2 Pi
= 2 ci + 6 di (t i).
dt2

Ti+1 1- Pi Pi+1
:
dPi dPi+1
(Ti+1 ) = (Ti+1 ), ..
dt dt
bi + ci di = bi+1 ci+1 + 2 di+1 .
(10.1) (10.3) ai bi
i i + 1, Yi+1 Yi = 2 Yi ,
ci + ci+1 di 2 di+1 = 2 Yi . (10.4)
2-
:
d2 Pi d2 Pi+1
(Ti+1 ) = (Ti+1 ), ..
dt2 dt2
2 ci = 2 ci+1 6 di+1 ,
1
di+1 = (ci+1 ci ) . (10.5)
3

73
10.

i + 1 i (10.5)
1
di = (ci ci1 ) . (10.6)
3
(10.5) (10.6) (10.4)
ci1 , ci , ci+1 :
ci1 + 4 ci + ci+1 = 3 2 Yi . (10.7)

10.2.
ci ,
, -
. ( -
-
) 3- -
, .
3- :

d3 Pi
= 6 di .
dt3
, t, -
di . 3- -
(, (i + 1)-) ,

di = di+1 . (10.8)

(10.4)

ci + ci+1 3 di+1 = 2 Yi ,

(10.5)
1  1
di+1 = ci + ci+1 2 Yi = (ci+1 ci ) ;
3 3
1 2
ci = Yi . (10.9)
2
, 3-
. ,
,

74
3.

-
(10.9) i = 1 i = n 2 (..
). -
ci (.. ), -
, :
1 2
c1 = y1 ;
2
ci1 + 4 ci + ci+1 = 3 2 yi , i = 2, n 2; (10.10)
1 2
cn2 = yn2 .
2
, n = 6:

1 0 0 0 0 c1 0.5 2 Y1

1
4 1 0 0 c2 3 2 Y2


0 1 4 1 0 = 3 2 Y3 (10.11)
c3

0 0 1 4 1 c4 3 2
Y4

0 0 0 1 0 c5 0.5 2 Y4

, -
, -
, (. 11).
ci , i = 1, n 1. ai , bi di
:

ai = Yi , (10.12)
bi = Yi , i = 1, n 1; (10.13)
1
di = (ci ci1 ) , i = 2, n 1, (10.14)
3
d1 = d2 . (10.15)

i -
x , (. . 9.3).

10.3. MATLAB
spline(X, Y, x)
x Y X.

75
10.

-
.
, -
. MATLAB (
) -
\ /.
A~x = ~b, A ,
~
~x b -, \:
x = A\b;
~xA = ~b, ~x ~b -,
/:
x = b/A;
, (10.10) -
, -
~c .

10.4.
www.amcm.gubkin.ru,
AppendixA.xls.

1. (10.10) , -
, ~c .
2. , P1 (t) P2 (t)
Pn2 (t) Pn1 (t).
3. 1 . 9.4, .
.
4. -
250 (. A.4). , -
10 .
.
5. -
, Xi+1 Xi = hi .
.

Pi (x) = ai + bi (x Xi ) + ci (x Xi )2 + di (x Xi )3 .

76
3.

11.
11.1.

n n:

b1 c1 0 0 0 ... 0 x1 d1

a2
b2 c2 0 0 ... 0
x2 d
2



x3 d3

0 a3 b3 c3 0 ... 0

= . (11.1)

..



.
. .



0 ... 0 0 an1 bn1 cn1

xn1 d
n1


0 ... 0 0 0 an bn xn dn

. , -
, -
, -
. ,
, x1 , ..., xn .

11.2.
(11.1) b1 . -

c1 d1
1 = , 1 = , (11.2)
b1 b1


1

1 1 0 0 0 ... 0 x1

a2 b2 c2 0 0 ... 0 x2
d
2



x3 d3

0 a3 b3 c3 0 ... 0

= . (11.3)

..



.
. .



0 ... 0 0 an1 bn1 cn1

xn1 d
n1


0 ... 0 0 0 an bn xn dn

77
11.

a2 . b2 = b2 /a2 ,
c2 = c2 /a2 , d2 = d2 /a2 :

1

1 1 0 0 0 ... 0 x1

d

1
b2 c2 0 0 ... 0
x2 2



x3 d3

0 a3 b3 c3 0 ... 0
= .

..

.


. .



0 ... 0 0 an1 bn1 cn1

xn1 d
n1


0 ... 0 0 0 an bn xn dn

, ,
. b2 = b2 1 , c2 = c2 , d2 = d2 1


1

1 1 0 0 0 ... 0 x1

d

0 b2 c2 0 0 ... 0 x2

2



x3 d3

0 a3 b3 c3 0 ... 0

= .

..



.
. .



0 ... 0 0 an1 bn1 cn1

xn1 d
n1


0 ... 0 0 0 an bn xn dn

b2 .

c2 c c2 /a2 c2
2 = = 2 = = ,

b2 b2 1 b2 /a2 1 b2 a2 1
d2 d 1 d2 /a2 1 d2 a2 1
2 = = 2 = = . (11.4)

b2 b2 1 b2 /a2 1 b2 a2 1


1

1 1 0 0 0 ... 0 x1



0 1 2 0 0 0 x2
... 2

x3 d3

0 a3 b3 c3 0 ... 0

= .

..



.
. .



0 ... 0 0 an1 bn1 cn1

xn1 d
n1


0 ... 0 0 0 an bn xn dn

78
3.

,
(11.3). a3 ,
, -
b3 . ,
3 , 3 .
, -
:

1

1 1 0 0 0 ... 0 x1



2

0
1 0 0 ... 0
x2 2


3

3 x3

0 0 1 0 ... 0
= .

..

.



. .


n1

0

... 0 0 0 1

xn1
n1
0 ... 0 0 0 an bn xn dn

, -
, . an , -
bn = bn /an , dn = dn /an . (n1)-
bn = bn n1 , dn = dn n1 .
bn .

dn d n1 dn /an n1 dn an n1
n = = n = = . (11.5)

bn bn n1 bn /an n1 bn an n1

, :

1

1 1 0 0 0 ... 0 x1



2

0
1 0 0 ... 0
x2 2


3

3 x3

0 0 1 0 ... 0
= . (11.6)

..

.

. .


n1

0

... 0 0 0 1

xn1
n1
0 ... 0 0 0 0 1 xn n

k k , -
, .

79
11.

(11.3). (11.4),
:
c1
1 = ,
b1
d1
1 = ,
b1
ck
k = , k = 2, n 1 (11.7)
bk ak k1
dk ak k1
k = , k = 2, n.
bk ak k1

k , k ,
n .

11.3.
,
, n- . ( (11.6)).
,
xn = n .
:

xn1 + n1 xn = n1

xn1 :

xn1 = n1 n1 xn .

xk = k k xk+1 .

11.4.
1. -
(10.11) .
2. -
\.

80
3.

12.
12.1. 2-
f (x, y) (Xi , Yj ),
i = 1, n, j = 1, m. Zij . ,
X~ = [X1 , X2 , ..., Xn ] Y
~ = [Y1 , Y2 , ..., Ym ] -, Z
, n m .
(Xi , Yj , Zij ) -
z(x, y), (n 1) (m 1).

(n 1) (m 1):
n
Y m
Y
lij (x, y) = (x Xk ) (y Yk ). (12.1)
k=1 k=1
k6=i k6=j


Xr , r 6= i, lij (Xr , y) = 0. , Yr , r 6= j -
lij (x, Yr ) = 0.
(Xi , Yj ), -
, wij :
n
Y m
Y
wij = lij (Xi , Yj ) = (Xi Xk ) (Yj Yk ).
k=1 k=1
k6=i k6=j


lij (x, y) pij :
n X
X m
z(x, y) = pij lij (x, y).
i=1 j=1

pij , z(x, y) -
(Xi , Yj , Zij ).
(Xi , Yj ) Zij :
z(Xi , Yj ) = pij lij (Xi , Yj ) = pij wij = Zij .
:
Zij
pij = .
wij

81
12.

,
. , j,


Xn n
Y Xm m
Y
x Xk y Yk
z(x, y) = Zij .
i=1
X i X k j=1 Yj Yk
k=1 k=1
k6=i k6=j

,
:
n
Y m
Y
x Xk y Yk
ai (x) = ; bj (y) = (12.2)
Xi Xk Yj Yk
k=1 k=1
k6=i k6=j

-: ~a(x) = [a1 (x), a2 (x), ..., an (x)]


~b(y) = [b1 (y), b2 (y), ..., bm (y)] .
:

X n Xm
z(x, y) = ai (x) Zij bj (y) = ~a (x) Z ~b(y). (12.3)
i=1 j=1

12.2. 2-
,
, .
( 3-)
, -
xOy, , .

,
, .
, -
, , -
.
1. (Xi , Yj ), i = 1, n,
j = 1, m, ,
, (xk , yl ), k = 1, N , l = 1, M .

82
3.

, y, -
, y = Yj (. 12.1a).
z(xk , Yj ) xk , Xi .
j 1 m, z(xk , Yj ) (-
. 12.1a).
2. x xk ,
, . -
z(xk , yl ) yl ,
Yj .
k 1 N , z(xk , yl ) (
. 12.1b).

a) I b) II
y y

la ements

Yj

x xk x

, I
, II

. 12.1.

1. (xk , yl ) ,
x, y, Xi+1 Xi
xk+1 xk Yj+1 Yj yl+1 yl . ..
(xk , yl ) (Xi , Yj ).

-
, -

83
12.

, -
.
2.
, -
, -
.

12.3.
(Xi , Yj ) -
. ,
, .
-
.
f (x, y) n , Zi = f (Xi , Yi ).
, -
. z(x, y)
.
i- :

di (x, y) = (x Xi )2 + (y Yi )2 .

wi (x, y) (x, y) i -
, (x, y) :
1
wi (x, y) = , di (x, y) 6= 0, (12.4)
di (x, y)p
p ,
. 1, 2, 3 ..
wi (Xi , Yi ) ,
(z(Xi , Yi ) = Zi ), -
z(x, y) .
(x, y)
P n

wi (x, y) Zi



i=1n , di (x, y) 6= 0 i = 1, n,
z(x, y) = P (12.5)
w i (x, y)

i=1



zi , i : di (x, y) = 0.

84
3.

, (x, y) -
z(x, y).
, -
(x, y). -
, -
. (12.5) n
, .
z(x, y) -
(x, y). ,
:
z z
(Xi , Yi ) = (Xi , Yi ) = 0,
x y
. -
,

.

12.4.
www.amcm.gubkin.ru,
AppendixA.xls.
1. , -

S(x, y) (. A.5). 100
.
2. , -
(.. -
).
3. , -

(. A.6) 30 -
x, h.
4. ,
.
5. (12.5) -
.
6.
, p,
.

85
4.

13.
13.1.
y = y(x),
Y ~ = [Y1 , Y2 , ..., Yn ]
X~ = [X1 , X2 , ..., Xn ] , n ,
, .. -
.
,
.

-
, , -
. -
, .

(). y = y(x, )
, ,
, .

Yi Yi = y(Xi , ). -
(. 13.1)

i = Yi Yi , ~ = Y ~b .
~ Y


n
X
S= 2i = ~ ~.
i=1

86
4.

Ybi o
i
Yi

Xi x
. 13.1.


(. . 13.4).

13.2.
y =
, y = . -
:
n
X n
X
S= 2i = (Yi )2 .
i=1 i=1

,
S(). :

, .. ,
dS
0;
d
, ,
d2 S
, .. 2
d
~ ~
X Y (
, 0).

87
13.

:
n n n
dS d X X X
= (Yi )2 = 2 (Yi )(1) = 2 ( Yi ) =
d d i=1 i=1 i=1
n
!
X
= 2 n Yi = 0.
i=1


n
1X
= Yi = Y ,
n i=1
Y Yi .
, . -
:
n
!
d2 S d X
=2 n Yi = 2 n > 0.
d2 d i=1

, -
= Y , , .
1. ,
S() ,
n
X n
X n
X
S= (Yi )2 = n2 + Yi + Yi2 ,
i=1 i=1 i=1

.. , , S()
2

, .
S() -
:
n
X
S = S() = (Yi )2 ,
i=1
, -
Xi . S
n -
, .. :
s
S
s = .
n

88
4.

q 2.
S
s = n1 , ,
n
.
,
, , -
,
2s 95%, 3s -
99.97%.

s
S
= 2s = 2 . (13.1)
n

y = x
, y = x.

i = Yi Xi .


n
X n
X
2i = (Yi Xi ) .
2
S=
i=1 i=1

:
n n
dS d X X
= (Yi Xi )2 = 2 (Yi Xi )(Xi ) =
d d i=1 i=1
n n n
!
X X X
= 2 (Xi2 Xi Yi ) = 2 Xi2 Xi Yi = 0.
i=1 i=1 i=1


P
n
Xi Yi ~ Y
~
X
= i=1
Pn = .
~ X
X ~
Xi2
i=1

89
13.

. -
:
n n
! n
d2 S X X X
= 2 X 2
i X Y
i i = 2 Xi2 > 0.
d2 i=1 i=1 i=1

, -
, , .
, -
(13.1).

13.3.
:

y = 1 + 2 x.

i = Yi (1 + 2 Xi ),
Xn n
X
S = 2i = (Yi (1 + 2 Xi ))2 .
i=1 i=1

, -
j , j = 1, 2 .
(. 13.2).

90
4.


0 5

S 5 S 0

10
2 5
2
0 2 2
0
0 0
2 2 2
1 2 2 2
1

20

10
S 0 S 5

0
20 2
2

0 0 2

2 0
2 2
2
0 2 2 2
1
1

. 13.2.

, , -
; 1 .
1 ,

; ( )
.

91
13.

1 :
n
S X
= (Yi (1 + 2 Xi ))2 =
1 1 i=1
n
X
= 2 (Yi (1 + 2 Xi )) (1) =
i=1
Xn n
X n
X
= 2 1 + 2 2 Xi 2 Yi =
i=1 i=1 i=1
Xn n
X
= 2 n1 + 2 2 Xi 2 Yi = 0.
i=1 i=1

2 :
n
S X
(Yi (1 + 2 Xi )) =
2
=
2 2 i=1
n
X
= 2 (Yi (1 + 2 Xi )) (Xi ) =
i=1
Xn n
X n
X
= 2 1 Xi + 2 2 Xi2 2 Xi Yi =
i=1 i=1 i=1
n
X n
X Xn
= 2 1 Xi + 2 2 Xi2 2 Xi Yi = 0.
i=1 i=1 i=1

2 :

Pn Pn
1 n
+ 2 Xi = Yi ,
i=1 i=1
P
n Pn Pn
1
Xi + 2 Xi2 = Xi Yi .
i=1 i=1 i=1

n ,
1 Pn 1 Pn
X = Xi Y = Yi ,
n i=1 n i=1

1 = Y 2 X. (13.2)

92
4.

, -
,
~ Y
X ~ nX Y
2 = . (13.3)
~
XX ~ nX X

. n -
, , -
:

1 P
n
n (Xi X)(Yi Y )
2 = i=1
P
n 2 ,
1
n Xi X
i=1

x
y, x.
[1 , 2 ], -
, . -
,
[1 , 2 ]:
n
X n
X
(Yi (1 + 2 Xi )) = n21 + 2 1 2
2
S = Xi +
i=1 i=1
n
X n
X n
X Xn
+ 22 Xi2 2 1 Yi 2 2 Xi Yi + Yi2 .
i=1 i=1 i=1 i=1

2 S(1 )
. 21 ( n) ,
, . ,
1 S(2 ) -
, ,
Pn
22 ( Xi2 ) . ,
i=1
S .

, (
) ,
.

93
13.

d2 S
= 2 n,
d21
n
X
d2 S
= 2 Xi2 ,
d22 i=1
2 Xn
d S d2 S
= =2 Xi .
d1 d2 d2 d1 i=1

,

Pn
n Xi
H = 2
Pn
i=1
P 2 .
n

Xi Xi
i=1 i=1

H ,
~ = [1 , 2 ] ~ H~ 0. .
H0 = H/2
:

Pn
n Xi " #
~ H0~ = [ ]
1 2
i=1 1
P
n P n =
Xi Xi2 2
i=1 i=1
n
X n
X
= n21 + 2 Xi 1 2 + Xi2 22 =
i=1 i=1
n
X n
 X
= 21 + 2 Xi 1 2 + Xi2 22 = (1 + Xi 2 )2 .
i=1 i=1

1
2 , , (13.2)-(13.3)
.
, , -
, ,
, (13.1).

94
4.

13.4.
, -
m:
m
X
y= j xj = ~x ~. (13.4)
j=1

xj ,
. -
n m:

X11 X12 X13 ... X1m

X
21 X22 X23 ... X2m
X= . , (13.5)
..

Xn1 Xn2 Xn3 ... Xnm
j- xj .
(13.4)
:
m
X
Yi = j Xij , i = 1, n.
j=1

:
b
Y~ = X~. (13.6)
-

m
X
i = Yi Yi = Yi j Xij ,
j=1

~ = Y ~b = Y
~ Y ~ X~,


2
n
X n
X m
X
S = ~ ~ = 2i = Yi j Xij .
i=1 i=1 j=1

95
13.

, -
k :
2
n m
S X X
= Yi j Xij =
k k i=1 j=1

Xn Xm
= 2 Xik Yi j Xij =
i=1 j=1

n
X Xm
= 2 j Xik Xij Xik Yi =
i=1 j=1
m
X n
X n
X
= 2 j Xik Xij 2 Xik Yi = 0, k = 1, m.
j=1 i=1 i=1

P
n
Akj = Xik Xij , Akj -
i=1
A = X X.
Xm Xn
S
=2 Akj j 2 Xik Yi = 0.
k j=1 i=1

( -
P
m P
n
), Akj j k- A~ = X X~, Xik Yi
j=1 i=1
~.
k- X Y
( -
) S, :

S = 2X X~ 2X Y
~ = 0, (13.7)

..
X X~ = X Y~ . (13.8)
, -
det(X X) 6= 0, ,
X . -
,

96
4.

. -
, ~
. ( X X) -
.
, cond(X X), -
.
X X -
, (13.8) , .

,
. :
Xn
2S
= 2Akj = 2 Xik Xij ,
k j i=1

.. H = 2X X. ,

~ X X~ = (X~) (X~) 0,
b
.. ~ -
S(~).

N
~x,
N m:
x11 x12 x13 ... x1m

x
21 x22 x23 ... x2m
x= . . (13.9)
..

xN 1 xN 2 xN 3 ... xN m
, (13.6),
b
~y = x~. (13.10)

13.5.

. ,
.

97
13.


, -
. -
, X
(13.8).
13.1. X1 , X2 , ..., Xn -
Y1 , Y2 , ..., Yn .

y = 1 + 2 x + 3 x2 + 4 ln(x).

: x1 1, x2 = x, x3 = x2 , x4 = ln(x).
X

1 X1 X12 ln(X1 )

1 X X22 ln(X2 )
2
X= .. .
.

2
1 Xn Xn ln(Xn )

b
(13.8) ~ = [1 , 2 , 3 , 4 ] .
13.2. X1 , X2 , ..., Xn -
Y1 , Y2 , ..., Yn .
1
y= .
1 + 2 x
1
: y1 = -
y

y1 = 1 + 2 x.
b
(13.8) ~ = [1 , 2 ] ,
.
-
.
(13.8). , -
x2 x , x11 x10

98
4.

(. 13.3), -
j .

x2 x11
4 1200

3.5
1000
3
800
2.5

2 600

1.5
400
1
200
0.5

0 0
0 0.5 1 1.5 2 0 100 200 300 400 500 600 700
x x10

. 13.3. x

-
,
(. 14).
-
,
, .
-
(, x y),
.


(13.1)
. ?
,
. 1 ,
2 , 1 > 2 .
1 2
2
,
, .. . -
,
.

99
13.

-
.
,
, .
-
, ,
.



, , -
.
13.3. X1 , X2 , ..., Xn -
Y1 , Y2 , ..., Yn .
y = 1 x2 e3 x .
:
ln(y) = ln(1 ) + 2 ln(x) + 3 x,
:
y1 = ln(y), x1 1, x2 = ln(x), x3 = x,
01 = ln(1 ).
, [01 , 2 , 3 ] . 1 = e1
0



, . -
-
( -
, ..). -
, C , ,
:

1, C ,
I{C} =

0, C .

100
4.

C ( C)
, I{C} = 1 I{C}.
13.4. -
x0 , x0
.
x0 :

y1 = 1 + 2 x

x0 :
y2 = 3 + 2 x.
I{x < x0 } :

y = 1 I{x < x0 } + 3 (1 I{x < x0 }) + 2 x.

1 ,
3 .
-
, .
13.5. -
, , -.
T .
? , -
, , ,
. :
4 2.
-
-.
3 , Ik ,
k = {1, 2, 3}. :

T (~x) = 1 I1 + 2 I2 + 3 I3 + 4 x1 + 5 x2 + ...

. -
. ,
- , -
.

101
13.

13.6. MATLAB

MATLAB ,
(regress(), glmfit() .). -
, ,
(13.8) -
(, \ . . 10.3) -
.
:
(. . 2.5);
y( (13.4));
X (
(13.5));
b
~ ( (13.8));
Y ~b (-
(13.6));
( (13.1));
x ( (13.9));
Y ~b (-
(13.10));
(. 3 4).


X
y = 1 + 2 x. -
, Xi ,
.. Xi -,
X. ones(),
X .
(. . 2.3):
Xmat = [X.^0 X];
-
: -
. MATLAB ,

102
4.

. ,
, .
X x -
, X , x
. -
. , -
,
.
M-, -
. :
_ = @()
, , -
f (x, y) = 2 x2 3 y 2 + 1:
f = @(x, y) 2*x.^2 - 3*y.^2 + 1;
, -
,
.
,
. -
,
. -
,
.
, , -
M-, .
-
:
F = @(x) [x.^0 x];
Xmat = F(X);
x ,
F(X) X.
x,
, -
.
. : -, -

.

103
13.

3D-
. 4.3, -
ndgrid() ,
.. xGrid yGrid, -
(xGrid(i, j), yGrid(i, j)) z(i, j). -
(13.10), -
x.
- , . ?
xGrid yGrid !
z, ,
xGrid yGrid.
reshape():
B = reshape(A, n, m); % ,
B = reshape(A, [n, m]);
reshape() B
n m . , -
, ,
.. ([]),
reshape()
.
:
A = [1 4 7 10
2 5 8 11
3 6 9 12];
B = reshape(A, 2, 6)
B =
1 3 5 7 9 11
2 4 6 8 10 12
C = reshape(A, 4, [ ])
C =
1 5 9
2 6 10
3 7 11
4 8 12
D = reshape(A, 1, [ ])
D = 1 2 3 4 5 6 7 8 9 10 11 12

104
4.

xGrid yGrid
-, .. reshape()
1:
xGridCol = reshape(Xgrid, [ ], 1);
z
, reshape(), -
xGrid size():
zGrid = reshape(z, size(xGrid));

mesh() surf().


-
X , ( )
( ). MATLAB
(>,<,== .. . . 5.1 5.2) -
0 1. , . ,
, - X = [1 2 3 4 5] -
x < 4. ind = X < 4
- X.

13.7.
www.amcm.gubkin.ru,
AppendixB.xls.

1. (. B.1), -
. -
, .
, .
2. -
(. B.2),
. 2-3
,
.

105
13.

3. -
,
p.
.
4. (. B.3),
.
. MATLAB -
, NaN.
5. (. B.4), -
. -
, ( -
).
,
.

106
4.

14.
14.1.
14.1. x1 x2 , n
, X11 , X21 , ..., Xn1 ; X12 , X22 , ..., Xn2 . -
x1 x2 X11 , X21 , ..., Xn1 ;
X12 , X22 , ..., Xn2
n
X
x1 x2 = Xi1 Xi2 . (14.1)
i=1

14.2. x1 x2 , -
X11 , X21 , ..., Xn1 ; X12 , X22 , ..., Xn2 ,
, x1 x2 = 0.
14.3. x
, x2 = xx.
, -
.
x1 , ..., xm , ~y, -
. X X , -
, x2k , k = 1, m.
(X X)1 , -
1
2 .
xk
X X , -

max(x2k )
cond(X X) = .
min(x2k )

s
p Pn
x2k = 2 , cond(X X) = 1.
Xik
i=1
p
, x2k xk !
, .
, -
(13.8), X X~ = X Y~ . X Y~

107
14.

xk y. -

xk y
k = , k = 1, m. (14.2)
x2k

k y -
xk , . ..

.

14.2.

. -
.
y x. -
. -

x1 = 1, x2 = x, x3 = x2 ,..., xm = xm1 . , -
, -
, - , xk xk+1
k > 10 , xk+1 xxk . , ,
xk ,
.
.
14.4. x,
F (x) G(x), n , X1 , X2 , ..., Xn . -
F G
X1 , X2 , ..., Xn
n
X
FG = F (Xi )G(Xi ). (14.3)
i=1

14.5. F (x) G(x) -


X1 , X2 , ..., Xn ,
, F G = 0.
-
P
n
x, xF G = Xi F (Xi )G(Xi ). ,
i=1

108
4.

-
0.
.

1. . a = const,
n
X n
X
(aF )G = aF (Xi )G(Xi ) = a F (Xi )G(Xi ) = a(F G),
i=1 i=1
Xn n
X
x(aF )G = Xi aF (Xi )G(Xi ) = a Xi F (Xi )G(Xi ) = a(xF G).
i=1 i=1

F (aG) = a(F G) xF (aG) = a(xF G).


2. .
n
X
F (G + H) = F (Xi )(G(Xi ) + H(Xi )) =
i=1
Xn n
X
= F (Xi )G(Xi ) + F (Xi )H(Xi ) = F G + F H,
i=1 i=1
Xn
xF (G + H) = Xi F (Xi )(G(Xi ) + H(Xi )) =
i=1
Xn n
X
= Xi F (Xi )G(Xi ) + Xi F (Xi )H(Xi ) = xF G + xF H.
i=1 i=1

(F + G)H = F H + GH,
x(F + G)H = xF H + xGH.

3. x. H(x) = xG(x). -
F H
F G:
n
X n
X
FH = F (Xi )H(Xi ) = F (Xi )Xi G(Xi ) = xF G.
i=1 i=1

109
14.

. -
:

P0 (x) 1, (14.4)
P1 (x) = x a1 , (14.5)
Pk (x) = (x ak ) Pk1 (x) bk Pk2 (x), k = 2, m 1. (14.6)

ak bk -
:
Pk Pk1 = 0, Pk Pk2 = 0.
a1 . P0 ,
P1

P1 (x) = xP0 (x) a1 P0 (x).

P0 P1 = P0 (xP0 a1 P0 ) = xP0 P0 a1 P02 = 0.

n
xP0 P0 1X
a1 = 2 = Xi = X. (14.7)
P0 n i=1
ak :

Pk Pk1 = ((x ak )Pk1 bk Pk2 ) Pk1 =


2
= xPk1 Pk1 ak Pk1 bk Pk2 Pk1 = 0.

, Pk1 Pk2 = 0,
xPk1 Pk1
ak = 2 . (14.8)
Pk1

, , bk :

Pk Pk2 = ((x ak )Pk1 bk Pk2 ) Pk2 =


2
= xPk1 Pk2 ak Pk1 Pk2 bk Pk2 = 0.

, Pk1 Pk2 = 0,
xPk1 Pk2
bk = 2 . (14.9)
Pk2

110
4.

xk = Pk1 (x) -

m
X
y= k Pk1 (x).
k=1

P0 (x), ..., Pm (x) , -


(14.2):

Pk1 y
k = 2 .
Pk1

14.3.
-
, .
x -
, X1 < X2 < ... < Xn , :
Xn X1
h = Xi+1 Xi = = const .
n1
x t , -
[0, 2 h]:

x X1
t = 2 ,
Xn X1 + h
, Xi

Xi X1 (i 1)h i1
Ti = 2 = 2 = 2 , i = 1, n.
Xn X1 + h (n 1)h + h n


m
a0 X
y= + (ak cos(k t) + bk sin(k t)) .
2
k=1

111
14.

1
, cos(k t), sin(k t) :
2
n
X n
X
sin(p Ti ) sin(q Ti ) = 0, cos(p Ti ) cos(q Ti ) = 0, p 6= q;
i=1 i=1
Xn
sin(p Ti ) cos(q Ti ) = 0;
i=1
n n
1X 1X
sin(q Ti ) = 0; cos(p Ti ) = 0,
2 i=1 2 i=1

p, q = 1, m.
-
(14.2):
P
n
Yi /2 n
i=1 2X
a0 = Pn = Yi ;
n i=1
1/22
i=1
Pn
Yi cos(k Ti ) n
i=1 2X
ak = Pn = Yi cos(k Ti );
n i=1
cos2 (k Ti )
i=1
P
n
Yi sin(k Ti ) n
i=1 2X
bk = Pn = Yi sin(k Ti ),
n i=1
sin2 (k Ti )
i=1

k = 1, m.
x ,
, , -
. , -
, X X
.
x t
h = (Xn X1 )/(n 1).

112
4.

15. -

15.1. -
, -
. -
,
. -
. -
( )
( )
. -
, -
.
( ),
. , -
.
,
, -
. :
.
. -
,
. ,
, -
.
,
.
.
Y1 , Y2 , ..., YN X1 , X2 , ..., XN ,
, X = Xi+1 Xi = const.
i. n,
. ,
, , ,
, . ,
: r , r ,
i. n = 2 r + 1.

113
15.

:
x Xi
t= ,
X
T~ = [r, r+1, ..., 1, 0, 1, ..., r],
. ,
,
~ = [Yir , ..., Yi , ...Yi+r ] .
W

, m,
m < n: m+1
X
w(t) = j tj1 . (15.1)
j=1
yi t = 0,
. 1 ,
P
m+1
w(0) = j 0j1 = 1 .
j=1

yi

Yi

Xi x
. 15.1.

, -
1 .
(m = 1) (13.2) :

yi = 1 = W 2 T = W ,

114
4.

1 Pn
T = tk = 0.
n k=1
, -
.
.
. k
Pn
tkj = 0, -
j=1

. , -
w(t) = .
(13.8) ~ -
T T~ = T W ~ , T -
m
1, t, ..., t , n (m + 1).
~ = (T T)1 T W
~,

, yi = 1 (T T)1 T W ~ , ..
1
(T T) T -
~ . ~h = [h1 , ..., hn ],
W
, -
:
Xn
yi = ~h W
~ = hk Wk . (15.2)
k=1

~h . -
. -
-
. ...,
1964- .
- :
P
n
, hk = 1;
k=1
,
hk = hnk+1 k r.
. - -
, Xi+1 Xi = Xi 6= const.
T i, -
.

115
15.


i = r + 1, N r,

:

1. -
;
2. , -
r, 0 N + 1, N + r;
3. (15.1) t = 0,
; -
;
4. (15.2) -
, : r ,
.


, ,
(. ), -
() ().

15.2. -

-
, . -
: .
-
, , :
h i
~h = 1 1 1 2 1 1 .
6

.
, -
, :
h i
~h = 1 1 2 3 4 3 2 1 .
16

116
4.

15.3.
,

:

Zt
1 u2
(t) = e 2 du.
2

0,
t = 0. -
,
[3 , 3 ] 99%,
. , n
r = (n 1)/2, r/3. -

 
r + 0.5
h1 = ,

   
tk + 0.5 tk 0.5
hk = , k = 2, n 1,

 
r 0.5
hn = 1 .


,
.

,

(t), -

1 t2
(t) = (t) = e 2 .
2
-
, : -
.

117
15.


  -
tk
. Hk = , :

Hk
hk = P
n .
Hj
j=1


. 1 2 ,
, -
.

0.7


0.6

0.5

0.4

0.3

0.2

0.1

0
2 1 0 1 2
t
. 15.2. n = 5

15.4.
1. .
,
/ .
2. .
, -
. ,
( ),
.. .
, -
.

118
4.

. -
.
1. Qt , . 3 , -
1 , .. N = 3600.
,
. . -
, .
Qt
403.5

403

402.5

402

401.5

401

400.5

400

399.5

399
0 500 1000 1500 2000 2500 3000 3500 4000
t

. 15.3. n = 51
, -
.
Qt
403.5

403

402.5

402

401.5

401

400.5

400

399.5

399
0 500 1000 1500 2000 2500 3000 3500 4000
t

. 15.4. n = 201
.

119
15.

15.5. MATLAB
smooth(Y, n) -
~ n,
Y
. - -
sgolay ,
m:

y = smooth(Y, n, sgolay, m);

smooth() -
, ,
, -
, .
imfilter(), -
(. . 16.4).

~
X:
y = smooth(X, Y, n, sgolay, m);
smooth() -
.

15.6.
www.amcm.gubkin.ru,
AppendixB.xls.

1. ,
. .
2. ,
-. -
.
3. ,
. .

120
4.

16. -

16.1. -
z(x, y) , Zij = z(Xi , Yj ), i = 1, N ,
j = 1, M . , x, y, ..
Xi+1 Xi = X = const, Yj+1 Yj = Y = const.
(Xi , Yj ),
:
x Xi y Yj
t= , s= .
X Y

n = 2 r + 1, m = 2 l + 1.
(Tu , Sv ),

T~ = [r, r + 1, ..., 1, 0, 1, ..., r];


S~ = [l, l + 1, ..., 1, 0, 1, ..., l].

. , -
, :

Zir,jl . . . Zir,j . . . Zir,j
.. .. ..

. . .


W = Zi,jl . . . Zi,j . . . Zi,j
.. .. ..

. . .
Zi+r,jl . . . Zi+r,j . . . Zi+r,j

z(x, y) (Xi , Yj )
(U 1) (V 1):
U X
X V
wij (t, s) = uv tu1 sv1 . (16.1)
u=1 v=1

t = 0, s = 0:

zij = wij (0, 0) = 11 .

121
16.

~, -
(13.8). W
- W ~ nm, T~
~
S T, -
tu sv , u = 0, U 1, v = 0, V 1.
t s, .. -
T nm U V . (13.8)

T T~ = T W
~,

~ = (T T)1 T W
~,

, zij -
~ , ..
(T T)1 T W
1
(T T) T W ~ . , ( -
~
nm) h ,
h n m.

Xn Xm
zij = ~h W
~ = hpq Wpq .
p=1 q=1

(U = 1, V = 1) (U = 2, V = 2)
-
( ), -
.

MATLAB
t s, -
, . 13.6, ndgrid(), .. -
T~ S
~ n m.
reshape() -.
W. -
.
~h nm
h n m
reshape().

122
4.


, -
:
P
n P
m
, hpq = 1;
p=1 q=1
:

hpq = hnp+1,mq+1 p r q l.

, ,
.
, ,
: -
, , -
(16.1), , , -
uv . ,
. , ,
.
, -
. , ,
, .

16.2. -

, , ,
. -
: 1
h
.
-
n = m = 5:

1 1 1 1 1

1 1 1 1 1
1

h= 1 1 2 1 1 ,
26

1 1 1 1 1
1 1 1 1 1

123
16.

:

1 1 1 1 1

1 2 2 2 1
1


h= 2 3 2 1 .
35 1

1 2 2 2 1
1 1 1 1 1
n = m,
.. h .

16.3.
,


. -
, x = r/3, y = l/3. -
x y ,
[tp 0.5, tp + 0.5] [sq 0.5, sq + 0.5]
.
, .
t s
   
t t
F (t) = , G(s) = .
x y

h11 = F (r + 0.5) G(l + 0.5),
hn,m = (1 F (r 0.5)) (1 G(l 0.5)) ,
h1,m = F (r + 0.5) (1 G(l 0.5)) ,
hn,1 = (1 F (r 0.5)) G(l 0.5),
h1,q = F (r + 0.5) (G(sq + 0.5) G(sq 0.5)) ,
hp,1 = (F (tp + 0.5) F (tp 0.5)) G(l + 0.5),
hp,m = (F (tp + 0.5) F (tp 0.5)) (1 G(l 0.5)) ,
hn,q = (1 F (r 0.5)) (G(sq + 0.5) G(sq 0.5)) ,

124
4.

hp,q = (F (tp + 0.5) F (tp 0.5)) (G(sq + 0.5) G(sq 0.5)) ,


p = 2, n 1, q = 2, m 1,

, r = 3, l = 3

,

,
   
tp sq
Hpq = ,
x y

:
Hpq
hpq = P
n P
m .
Huv
u=1 v=1

. , 1 (2 ) -
, ,
.
2. ,
, 61 41 (. 16.1).

20

15 14
10 12

5 10
y z
0 8

5 6

10 4
20
15 20
0
20 0
20 10 0 10 20
x y 20 20 x

. 16.1.

125
16.

15 15. -
(. 16.2).

10
11
5
y z
0 10

5 9
10
0 10
10 0
10 0 10 y 10 10 x
x

. 16.2.

, , .
. -
.

16.4. MATLAB
-
fspecial(type, parametres),
. , h=fspecial(average, [n, m]) -
() n m,
h=fspecial(gaussian, [n, m], r/3) (-
) n m -
= r/3. -
, ,
, -
.
h imfilter(Z, h),
Z, -

, . -

126
4.

,
symmetric.

:
h = fspecial(average, [15, 15]);
z0 = imfilter(Z, h, symmetric);
z = imfilter(z0, h, symmetric);

16.5.
www.amcm.gubkin.ru,
AppendixB.xls.

1. ,
. .
2. ,
-. -
.
3. ,
. .

127

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1. MATLAB
1. MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1. MATLAB. M- . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.1. plot(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4. 3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.1. f or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.2. if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.3. - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

2.

128

6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.1. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.3. .. . . . . . . . . . . . . . . . . . . . . . . . . 45
6.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.4. : . . . . . . . . . . . . . . . 51
6.5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7. . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.1. 54
7.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.3. MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8. . . . . . . . . . 61
8.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
8.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
8.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

3.
9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
9.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
9.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
9.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
9.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
10.3. MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
10.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

129

11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
11.1. . . . . . . . . . . . . . . . . . 77
11.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
11.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
11.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
12.1. 2- . . . . . . . . . . . . . . . . . . . . . . . . . 81
12.2. 2- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
12.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
12.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

4.
13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
13.6. MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
13.7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
14.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
14.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
14.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
15. 113
15.1. - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
15.2. . . . 116
15.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
15.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
15.5. MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
15.6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

130

16. . 121
16.1. - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
16.2. . . . 123
16.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
16.4. MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
16.5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

131