|
Mustaqil ish fan: Amaliy dasturiy paketlar
|
bet | 5/8 | Sana | 27.05.2024 | Hajmi | 232,03 Kb. | | #255039 |
Bog'liq Matlab tizimida matritsalar ustida arifmetik amallar bajarish1 1 1 -1 -1
>> tril (A)
ans =
0 0 0 0 0
1 0 0 0 0
-2 -1 0 0 0
-2 3 -1 -1 0
Endi shu buyruqni o’zimiz m-faylga yozib yangi yuqori degan buyruq hosil qilamiz.
>> B=yuqori(A)
x = 5
B =
-1 0 0 0 0
-2 1 0 0 0
-2 -1 0 0 0
-2 3 -1 -1 0
1 1 1 -1 -1
triu(A) - buyrug’i esa matritsaning diagonalidan pastki qismini nollarga aylantirishni amalga oshiradi.
Misol. Berilgan matritsaning diagonaildan pastki qismini elementlarini 0 bilan almashtirish:
>> A=[-1 2 4 0 3; -2 1 0 3 4; -2 -1 0 -2 1; -2 3 -1 -1 1; 1 1 1 -1 -1]
A =
-1 2 4 0 3
-2 1 0 3 4
-2 -1 0 -2 1
-2 3 -1 -1 1
1 1 1 -1 -1
>> triu(A)
ans =
-1 2 4 0 3
0 1 0 3 4
0 0 0 -2 1
0 0 0 -1 1
0 0 0 0 -1
Ushbu triu protsedurasini algoritmini o’zimiz tuzib m-faylga yozib chiqamiz va quyidagi natijalarga erishamiz .
>> B=pastki(A)
x = 5
A =
-1 2 4 0 3
0 1 0 3 4
0 0 0 -2 1
0 0 0 -1 1
0 0 0 0 -1
RESHAPE - matrisa o’lchamini o’zgartishni amalga oshirdi.
>> A=[-1 0 2 0; 0 1 2 -1; -1 -2 -3 2]
A =
-1 0 2 0
0 1 2 -1
-1 -2 -3 2
>> reshape(A,2,6) % matritsa elementlarining soniga qarab ixtiyoriy
o`lchamdagi matritsani hosil qiladi.
ans =
-1 -1 1 2 -3 -1
0 0 -2 2 0 2
3 Matritsalarni maxsus ko’rinishda hosil qilish
ZEROS - masssiv elementlarini nollardan iborat qilib tuzadi.
Sintaksisi:
Y = Zeros(n)
Y = Zeros (m, n)
|
| |