-sort(-V)
– V massivni tartiblaydi (kamayish tartibi bo’yicha
saralaydi).
>> V=[-1 0 3 -2 1 -1 1];
>> -sort(-V)
ans =
3 1
1
0
-1
-1
-2
det(M)
–
M kvadrat matritsani hisoblaydi.
235
>> M=[3 2;4 3];
>> det(M)
ans = 1
rank(M)
–
M matritsa rangini aniqlaydi.
>> M=[1 -2 4 5;3 -1 -3 5;1 3 -11 -5] .
M =
-2 4 5
-1 -3 5
3 -11 -5
>> rank(M)
ans = 2
norm(M, p)
–
p (p=1, 2, inf, fro) ga bog’liq holda M matritsaning
normasini turli
ko’rinishlarda qaytaradi.
cond (M, p)
–
p normaga asoslangan M matritsa shartli qiymat sonini
qaytaradi.
Ushbu funksiyalarga doir misollar quyidagicha:
>> M=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10];
>> norm(M)
ans = 30.2887
>>M=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10];
>>cond(M)
ans = 2.9841e+003
eye (n, m)
yoki
eye (n)
–
kvadrat birlik matritsa yoki bosh diagonali
bo’yicha
birlik
to’g’ri to’rtburchakli matritsani qaytaradi.
cat (n, A, B)
yoki
cat (n, A, B, C, ...)
–
A va B matritsalarni birlashtiradi.
Misol:
>> A=[1 2;3 4];
>> B=[5 6;7 8];
>> cat(2,A,B)
ans =
236
1 5
6
4
7
8
>>[A,B]
ans =
2 5 6
4
7 8
>>cat(1,A,B)
ans =
1 2
3 4
5 6
7 8
inv(M)
–
M matritsaga teskari matritsani qaytaradi.
Misol:
>>M=[2 1 -5 1;1 -3 0 -6;0 2 -1 2;1 4 -7 6]
M =
1
-5
1
-3
0
-6
2
-1
2
4
-7
6
>>
P=inv
(M)
P =
1.3333 -0.6667 0.3333 -1.0000 -0.0741 0.2593
1.1481 -0.1111 0.3704 -0.2963 0.2593 -0.4444
0.2593 -0.4074 -0.5185 -0.1111
>> M*P % M*P=E ekanligini tekshirish
ans =
1.0000
-0.0000
-0.000
0.0000
01.0000 0.0000
0.0000
0.0000
-0.0000
1.0000
-0.0000
0.0000
-0.0000
-0.0000
1.0000
237
magic(n)
–
funksiyasi
n
n
o’lchamli sirli matritsani
beradi, yani barcha ustun
elementlari yig’indisi, barcha satr elementlari yig’indisi va hatto diagonal bo’yicha
elementlar yig’indisi bir xil songa teng bo’ladi.
Masalan:
>> M=magic(4)
M =
16 2
3
13
5
11
10
8
9
7
6
12
4
14
15
1
>>sum(M')
ans =
34 34 34 34
>>M=magic(10)
M =
92
99
1
8
15
67
74
51
58
40
98
80
7
14
16
73
55
57
64
41
4
81
88
20
22
54
56
63
70
47
85
87
19
21
3
60
62
69
71
28
86
93
25
2
9
61
68
75
52
34
17
24
76
83
90
42
49
26
33
65
23
5
82
89
91
48
30
32
39
66
79
6
13
95
97
29
31
38
45
72
10
12
94
96
78
35
37
44
46
53
11
18
100
77
84
36
43
50
27
59
>> sum(M')
ans =
505 505 505 505 505 505 505 505 505 505
>>M=magic(3)
M =
8
1
6
3
5
7
4 9 2
>> sum(M')
ans = 15 15 15
238
linsolve(A, b)
- A·x=b ko’rinishdagi chiziqli tenglamalar sistemasi
yechimini,
linsolve(A, b, options)
formatida tenglama yechish metodini berish imkonini
chaqiradi.
>>A=[2 -1 1;3 2 -5;1 3 -2];
>> b=[0;1;4];
>> x=linsolve(A,b) % chiziqli tenglamalar sistemasi yechish
x =
[ 13/28]
[ 47/28]
[ 3/4]
>>A*x %yechimni to’g’riligini tekshirish
ans =
[ 0]
[ 1]
[ 4]
MUHOKAMA UCHUN SAVOLLAR VA MUAMMOLI VAZIYATLAR!
1.
Vektor uzunligini aniqlash qanday funksiya yordamida amalga oshiriladi?
2.
Vektor elementlarining ko’paytmasi qanday bajariladi?
3.
Vektor elementlarining yig’indisi qanday bajariladi?
4.
Matritsalar ustida qanday funksuyalar bajarish mumkin?
5.
Teskari matritsa qanday aniqlanadi?
3-§. MATLAB dasturidagi maxsus buyruqlarining tasnifi
O’quv modullari
MATLAB paketiga tegishli funksiyalar, simplify
funksiyasi, simplify funksiyasi, expand funksiyasi, dsolve
funksiyasi
239
MATLAB paketiga tegishli funksiya va buyruqlarni quyidagi buyruq
yordamida olish mumkin:
help symbolic
>>Symbolic Math
Toolbox.
Calculus.
diff
- Differentiate.
int
- Integrate.
limit
- Limit.
taylor
- Taylor series.
jacobian
- Jacobian matrix.
symsum
- Summation of series.
Linear Algebra.
diag
- Create or extract diagonals.
triu
- Upper triangle.
tril
- Lower triangle.
inv
- Matrix inverse.
det
- Determinant.
rank
- Rank.
rref
- Reduced row echelon form.
null
- Basis for null space.
colspace
- Basis for column space.
eig
- Eigenvalues and eigenvectors.
svd
- Singular values and singular vectors.
jordan
- Jordan canonical (normal) form.
poly
- Characteristic polynomial.
expm
- Matrix exponential.
240
Simplification.
simplify
- Simplify.
expand
- Expand.
factor
- Factor.
collect
- Collect.
simple
- Search for shortest form.
numden
- Numerator and denominator.
horner
- Nested polynomial representation.
.................................................................................va boshqa buyruqlar ro’yxati
chiqariladi.
Yuqorida keltirilgan ayrim buyruqlarni ishlatilishi bilan tanishib chiqamiz:
1.
simplify
– bu funksiya ifodani soddalashtiradi.
Simvolli ob’ektlar guruhini yaratish uchun
syms
funksiyasi xizmat qiladi. Uning
umumiy ko’rinishi quyudagicha:
Syms arg1 arg2 … - bu simvolli ob’ektlar guruhini yaratadi.
Misollar ko’raylik:
6
>> syms a b x;
7
>> simplify((a^2 - 2*a*b + b^2) / (a - b))
ans = a-b
expand
–
bu funksiya qavslarni ochadi.
Misol:
8
>> syms a b x;
>> S=[(x + 2)*(x + 3)*(x + 4) sin(2*x)];
241
>> expand(S)
ans =
[ x^3+9*x^2+26*x+24,
2*sin(x)*cos(x)]
factor
– bu ifodani sodda ko’paytuvchilarga yoyadi.
х
= sym ('x')
– simvolli o’zgaruvchini ‘x’ nom bilan qaytaradi va natijani x ga
yozadi. Misol:
>> help sym/name.m
sym/name.m not found.
>>x=sym('x')
x = x
>>factor(x^7-1)
ans =
(x-1)*(x^6+x^5+x^4+x^3+x^2+x+1)
collect
– bu darajalari bo’yicha komplektlash.
collect(S,v)
funksiyasi S matritsa yoki vektor tarkibidagi ifodani v
o’zgaruvchi
darajasi bo’yicha komplektlash.
simple(S)
funksiyasi S massiv elementlarini turli soddalashtirshlarini
bajaradi.
numden
–
ratsional shaklga keltirish funksiyasi.Misol:
>>[n,d] = numden(sym(8/10))
n = 4
d = 5
Yuqoridagi misolda n suratni, d esa maxrajni bildiradi.
subs
– o’rniga qo’yishni ta’minlaydi.
diff
–
funksiyaning hosilasini oladi.
Misol:
>> help sym/name.m sym/name.m not found.
>> x=sym('x');y=sym('y');
>> diff(x^y)
ans = x^y*y/x
242
Natijani yana soddalashtirish mumkin. Buning uchun simplify (arg)
buyrug’idan foydalanamiz.
>>simplify(ans)
ans =
x^(y-1)*y
int
–
integrallash funksiyasi. Bu aniq va aniqmas integrallarni hisoblashda
ishlatiladi.
int
(S,a,b)
–
S funksiyaning (a,b) oraliqda aniq integralni qaytaradi (hisoblaydi).
Masalan:
>> int(sin(x)^3, x)
ans =
-1/3*sin(x)^2*cos(x)-2/3*cos(x)
>> int(log(2*x), x)
ans =
log(2*x)*x-x
limit
–
funksiya limitini hisoblaydi. Limit(F,x,a)
–
bu funksiya F simvolli
ifodaning
x=a nuqtada limitini aniqlaydi.
>>limit(sin(x)/x, x, 0)
ans =
1
taylor
- bu funksiya Teylor qatoriga yoyadi.
Misol:
>> x = sym('x')
x =
>> taylor(sin(x))
ans = x-
1/6*x^3+1/120*x^
5
solve
–
bu buyruq algebraik tenglama va tenglamalar sistemasining yechimini
aniqlaydi.
Misol:
>> syms x y;
>> solve(x^3 -1, x)
243
ans =
[1]
[ -1/2+1/2*i*3^(1/2)]
[ -1/2-1/2*i*3^(1/2)]
Ushbu x+y=3 sistemaning yechimini
solve
buyrug’idan
xy
2
=
4 foydalanib
aniqlash quyidagicha:
>> S = solve('x+y=3', 'x*y^2=4', x, y)
S =
x: [3x1 sym]
y: [3x1 sym]
>>S.x
ans =
[ 4]
[ 1]
[ 1]
>>S.y
ans =
[ -1] [ 2] [ 2]
|