|
|
bet | 4/5 | Sana | 26.02.2022 | Hajmi | 233,5 Kb. | | #468288 |
| Bog'liq 2-lobaratoriya mmmm
-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
>> tril(A) ans =
0 0 0 0
1 0 0 0
-2 -1 0 0 0
-2 3 -1 -1 0
1 1 1 -1 -1
Endi shu komandani o’zimiz m-faylga yozib yangi yuqori degan komanda hosil qilamiz :
>> B=yuqori(A)
x =
5
B =
0 0 0 0
1 0 0 0
-2 -1 0 0 0
-2 3 -1 -1 0
1 1 1 -1 -1
9 – misol :triu komandasi esa matritsaning diagonalidan pastki qismini nollarga aylantiradi:
>> 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]
=
2 4 0 3
1 0 3 4
2 -1 0 3
2 -1 1 3
1 -1 1 5
>> flipud(A) ans = 5
-1 2 4 0 3 9
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
=
2 4 0 3
0 1 0 3 4
0 0 0 -2 1
0 0 0 -1 1
0 0 0 0 -1
10 – misol : RESHAPE – matrisa o’lchamini o’zgartish :
>> 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) ans =
-1 -1 1 2 -3 -1
0 0 -2 2 0 2
V. Ishni bajarish tartibi:
Laboratoriya mashg’ulotida har bir talaba ilovada keltirilgan masalalarni Matlab\Simulink dasturida yechishi va yechimlarini hisobot shaklida topshirishi talab etiladi.
Ilovadagi masalalar
RESHAPE – matrisa o’lchamini o’zgartiring : A=[-1 0 3 0; 0 1 2 -1; -4 -2 -3 2];
Berilgan matritsaning diagonaildan yuqori qismini elementlarini 0 bilan almashtiring:
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];
Berilgan matritsaning diagonaildan pastkii qismini elementlarini 0 bilan almashtirish:
A=[-6 2 4 4 3; -2 1 0 3 4; -2 -1 0 -2 1; -2 3 -1 -1 1; 1 8 1 -1 -1]
Berilgan matritsaning diagonaildan elementlarini 0 bilan almashtirish:
A=[-2 2 4 0 3; -2 1 0 3 4; -2 -1 0 -2 1; -2 3 -1 -1 1; 1 5 1 -1 -1]
diag(A) komandasi berilgan matritsaning diagonalida tugan elementlarni ekranga chiqaring:
A=[-1 0 1; 0 -1 0; 1 -1 1]
diag(A) komandasi berilgan matritsaning diagonalida tugan elementlarni ekranga chiqaring:
A=[-3 5 1; 0 -1 0; 1 -6 1]
diag(A) komandasi berilgan matritsaning diagonalida tugan elementlarni ekranga chiqaring:
A=[-1 5 1; 0 -8 0; 1 -1 1]
Berilgan matritsani soat strelkasiga qarshi 900 ga burish uchun ishlatiladigan rot90(A) komandasi:
A=[-1 0 1; 0 -1 0; 1 -1 1]
Berilgan matritsani soat strelkasiga qarshi 450 ga burish uchun ishlatiladigan rot45(A) komandasi:
A=[-1 0 1; 0 -1 0; 1 -1 1]
Berilgan matritsani soat strelkasiga qarshi 1800 ga burish uchun ishlatiladigan rot180(A) komandasi:
A=[-1 0 1; 0 -1 0; 1 -1 1]
Matlabda matritsalarni yuqoridan pastga burishda flipud komandasidan foydalanish:
A=[-1 0 1; 0 -1 0; 1 -1 1]
Matlabda matritsalarni chapdan o’ngga burishda fliplr komandasidan foydalanish:
A=[-1 0 1; 0 -1 0; 1 -1 1]
Matlabda matritsalarni o`ngdan chapga burishda fliplr komandasidan foydalanish:
A=[-1 0 1; 0 -1 0; 1 -1 1]
Matlabda matritsalarni chapdan o’ngga burishda fliplr komandasidan foydalanish:
A=[-7 0 1; 0 -4 0; 1 -1 3]
Matlabda matritsalarni chapdan o’ngga burishda fliplr komandasidan foydalanish:
A=[-3 0 3; 0 -7 0; 1 -2 1]
A va B matritsalarni bir-biriga qo’shish
A=[-1 0 1; 0 -1 0; 1 -1 1];
B=[1 1 0; 2 -1 0; 3 8 1];
A va B matritsalarni bir-biriga qo’shish
A=[-1 7 1; 0 -5 0; 1 2 1];
B=[4 1 7; 2 -5 0; 3 0 1];
A va B matritsalarni bir-biriga ko`paytirish.
A=[-1 7 1; 0 -5 0; 1 2 1];
B=[4 1 7; 2 -5 0; 3 0 1];
A va B matritsalarni bir-biriga bo`lish.
A=[-1 7 1; 0 -5 0; 1 2 1];
B=[4 1 7; 2 -5 0; 3 0 1];
Matlab da for-loops va boshqa operatorlardan foydalanib nn o’lchamdagi ixtiѐriy A matrisaning ustunlarining yig’indisini hisoblovchi ustun_hisobi deb nomlangan m-faylni (m-file) yarating.
Do'stlaringiz bilan baham: |
|
|