• >> for i=1:3; for j=1:3; C(i,j)=A(j,3-i+1); end; end; C C = 1 0 1 0 -1 -1 -1 0 1 Misol.
  • >> length(A) ans = 3 >> ndims(A) ans =
  • Misol. Berilgan matritsani soat strelkasiga qarshi 900 ga burish uchun ishlatiladigan rot90(A) buyrug’i: >> A=[-1 0 1; 0 -1 0; 1 -1 1]




    Download 232,03 Kb.
    bet3/8
    Sana27.05.2024
    Hajmi232,03 Kb.
    #255039
    1   2   3   4   5   6   7   8
    Bog'liq
    Matlab tizimida matritsalar ustida arifmetik amallar bajarish

    Misol. Berilgan matritsani soat strelkasiga qarshi 900 ga burish uchun ishlatiladigan rot90(A) buyrug’i:
    >> A=[-1 0 1; 0 -1 0; 1 -1 1]
    A =
    -1 0 1
    0 -1 0
    1 -1 1
    >> rot90(A)
    ans =
    1 0 1
    0 -1 -1
    -1 0 1
    Endi shu amalning bajarilish tartibi ya’ni algoritmini keltiramiz:
    >> for i=1:3; for j=1:3; C(i,j)=A(j,3-i+1); end; end; C
    C =
    1 0 1
    0 -1 -1
    -1 0 1
    Misol. MATLABda matritsalarni chapdan o’ngga burishda fliplr buyrug’idan foydalanish:
    >> A=[-1 0 1; 0 -1 0; 1 -1 1]
    A =
    -1 0 1
    0 -1 0
    1 -1 1
    >> fliplr(A)
    ans =
    1 0 -1
    0 -1 0
    1 -1 1
    Undan tashqari MATLABda maxsus ko’rinishdagi matritsalarni hosil qilish
    imkoniyati bor. Ana shunday matritsalarni hosil qiluvchi buyruqlarni keltirib
    o’tamiz:
    >> A=[-1 0 1; 0 -1 0; 1 -1 1]
    A =
    -1 0 1
    0 -1 0
    1 -1 1
    >> size(A)
    ans = 3 3 % ya`ni matritsaning o`lchami (3x3) o`lchamga ega bo`ladi.
    >> length(A)
    ans = 3
    >> ndims(A)
    ans = % oxirgi hosil bo`lgan matritsaning elemntlari sonini chiqarish.
    2
    >> isempty(A)
    ans = 0 % matritsaning elementlari mavjud bo`lgani uchun 0 qiymat qaytaradi.
    Misol: Berilgan A va B matritsalarni bir biriga ko’paytirish:
    >> A=[-1 0 1; 0 -1 0; 1 -1 1]
    A =
    -1 0 1
    0 -1 0
    1 -1 1
    >> B=[1 1 0; 2 -1 0; 3 0 1]
    B =
    1 1 0
    2 -1 0
    3 0 1
    >> A*B
    ans =
    2 -1 1

    Download 232,03 Kb.
    1   2   3   4   5   6   7   8




    Download 232,03 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Misol. Berilgan matritsani soat strelkasiga qarshi 900 ga burish uchun ishlatiladigan rot90(A) buyrug’i: >> A=[-1 0 1; 0 -1 0; 1 -1 1]

    Download 232,03 Kb.