SlideShare a Scribd company logo
1 of 15
Matlab.
Pierwsze kroki w
algebrze
Autorzy:
Gracjana Wąsik
Brian Bartkowiak
Wprowadzenie wektora
 >>a = [1 2 3 4 5] i naciskamy ENTER 
 Wskazówka: Jeśli za nawiasem umieścimy
  średnik wartości wektora nie zostaną
  wyświetlone, ale pozostaną w pamięci.
Wprowadzenie wektora
 Drugisposób. Można utworzyć wektor w
  pewnym zakresie o elementach
  oddalonych od siebie o tę sama wartość:
 >> b=[0:3:12]
 >> c=[1:5]
Dodawanie wektorów
 Do każdego elementu wektora można
  dodać(odjąć) liczbę, np.
 >> b=a+1
 Albo dodać (odjąć) dwa wektory o tej
  samej długości:
 >> c=a+b
Operacje na wektorach
   max(x) zwraca największy element wektora x
   min(x) zwraca najmniejszy element wektora x
   sum (x) zwraca sumę elementów wektora x
   prod(x) – zwraca iloczyn elementów wektora
    x
   mean(x) – zwraca średnią arytmetyczną
    elementów wektora x
Wprowadzenie macierzy
   Macierz tworzymy podobnie jak wektor, ale:
   elementy w wierszu macierzy muszą być
    oddzielane spacją lub przecinkami
   średnik lub znak nowego wiersza kończy
    wiersz macierzy i powoduje przejście do
    następnego
   cała lista elementów musi być ujęta w
    nawiasy kwadratowe.
   >> A=[1 2 3; 4 5 6; 7 8 9]
Wprowadzenie macierzy
 Wierszemacierzy zachowują się jak
  wektory(bo to są wektory), tzn.
 >>A=[1:9; 2:2:18]
Wprowadzenie macierzy
 Macierze  można wprowadzać także
  poprzez zmienne, tzn.
 C=[A;B] – składanie w pionie,
 C=[A,B] – składanie w poziomie,
 C=[A,B;B,A] – składanie mieszane
Operacje na macierzach
 X*Y  – mnożenie macierzy, zgodnie z
  zasadami rachunku macierzowego
  (liczba kolumn X jest równa liczbie kolumn
  Y)
 X+Y – sumowanie macierzy
 X-Y – odejmowanie macierzy
 X’ – transpozycja macierzy
Operacje na elementach
macierzy
 X.*Y   – mnożenie elementów wektorów lub
  macierzy o tych samych indeksach tzn.
  X(i,j)*Y(i,j)
 X./Y – dzielenie elementów wektorów lub
  macierzy o tych samych indeksach tzn.
  X(i,j)/Y(i,j)
 X.^Y – podnoszenie do potęgi elementów
  wektorów lub macierzy o tych samych
  indeksach tzn. X(i,j)^Y(i,j)
Operacje na elementach
macierzy
 >>C=A’   – transponowanie macierzy,
 >>C=A^(-1) – odwrotność macierzy,
  pamiętajmy, że macierz odwrotna istnieje
  tylko dla macierzy kwadratowych!
Generowanie macierzy
   X=eye(5) – macierz jednostkowa 5x5,
   X=ones(5) – macierz jedynkowa 5x5 ,
   X=zeros(5) - macierz zerowa 5x5,
   X=rand(5) - macierz losowa 5x5,
   X=randn(5) - macierz losowa o rozkładzie
    normalnym 5x5,
   X=linspace(x1,x2,N) – wektor o wartościach
    rozłożonych równolegle
   X=logspace(x1,x2,N) – wektor o wartościach
    rozłożonych logarytmicznie
Dodatkowe informacje
   Macierz odwrotną wyznaczamy poleceniem :

    >> D=inv(A)

    jej wyznacznik:

    >> det(A)

    i wartości własne:

    >> eig(A)
Dodatkowe informacje
 >>A=diag(x) - macierz przekątniowa A ze
  składnikami wektora x na głównej
  przekątnej
 >>x=diag(A) - wektor x utworzony z
  elementów znajdujących się na głównej
  przekątnej macierzy A
Dodatkowe informacje:
   >> A(:,3) - wypisanie trzeciej kolumny macierzy A
   >> A(:,2:3) - wypisanie drugiej i trzeciej kolumny macierzy A
   >> A(:,2:-1:1) - wypisanie drugiej, a potem pierwszej kol. macierzy A
   >> A(:,2:1) - taki zapis daje wektor pusty
   >> A(2,:) - wypisanie drugiego wiersza macierzy A
   >> A(2:3,:) - wypisanie drugiego i trzeciego wiersza macierzy A
   >> A(:) - wszystkie elementy macierzy A jako wektor
   >> A(4:8) - elementy macierzy A od czwartego do ósmego
   >> A(end,:) - wypisanie ostatniego wiersza macierzy A
   >> X=A; X(2;:)=[] - usunięcie drugiego wiersza macierzy X
   >> Y=A; Y(1:2:8)=[] - usunięcie sekwencji elementów macierzy Y

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Matlab. Pierwsze kroki w algebrze.

  • 2. Wprowadzenie wektora  >>a = [1 2 3 4 5] i naciskamy ENTER   Wskazówka: Jeśli za nawiasem umieścimy średnik wartości wektora nie zostaną wyświetlone, ale pozostaną w pamięci.
  • 3. Wprowadzenie wektora  Drugisposób. Można utworzyć wektor w pewnym zakresie o elementach oddalonych od siebie o tę sama wartość:  >> b=[0:3:12]  >> c=[1:5]
  • 4. Dodawanie wektorów  Do każdego elementu wektora można dodać(odjąć) liczbę, np.  >> b=a+1  Albo dodać (odjąć) dwa wektory o tej samej długości:  >> c=a+b
  • 5. Operacje na wektorach  max(x) zwraca największy element wektora x  min(x) zwraca najmniejszy element wektora x  sum (x) zwraca sumę elementów wektora x  prod(x) – zwraca iloczyn elementów wektora x  mean(x) – zwraca średnią arytmetyczną elementów wektora x
  • 6. Wprowadzenie macierzy  Macierz tworzymy podobnie jak wektor, ale:  elementy w wierszu macierzy muszą być oddzielane spacją lub przecinkami  średnik lub znak nowego wiersza kończy wiersz macierzy i powoduje przejście do następnego  cała lista elementów musi być ujęta w nawiasy kwadratowe.  >> A=[1 2 3; 4 5 6; 7 8 9]
  • 7. Wprowadzenie macierzy  Wierszemacierzy zachowują się jak wektory(bo to są wektory), tzn.  >>A=[1:9; 2:2:18]
  • 8. Wprowadzenie macierzy  Macierze można wprowadzać także poprzez zmienne, tzn.  C=[A;B] – składanie w pionie,  C=[A,B] – składanie w poziomie,  C=[A,B;B,A] – składanie mieszane
  • 9. Operacje na macierzach  X*Y – mnożenie macierzy, zgodnie z zasadami rachunku macierzowego (liczba kolumn X jest równa liczbie kolumn Y)  X+Y – sumowanie macierzy  X-Y – odejmowanie macierzy  X’ – transpozycja macierzy
  • 10. Operacje na elementach macierzy  X.*Y – mnożenie elementów wektorów lub macierzy o tych samych indeksach tzn. X(i,j)*Y(i,j)  X./Y – dzielenie elementów wektorów lub macierzy o tych samych indeksach tzn. X(i,j)/Y(i,j)  X.^Y – podnoszenie do potęgi elementów wektorów lub macierzy o tych samych indeksach tzn. X(i,j)^Y(i,j)
  • 11. Operacje na elementach macierzy  >>C=A’ – transponowanie macierzy,  >>C=A^(-1) – odwrotność macierzy, pamiętajmy, że macierz odwrotna istnieje tylko dla macierzy kwadratowych!
  • 12. Generowanie macierzy  X=eye(5) – macierz jednostkowa 5x5,  X=ones(5) – macierz jedynkowa 5x5 ,  X=zeros(5) - macierz zerowa 5x5,  X=rand(5) - macierz losowa 5x5,  X=randn(5) - macierz losowa o rozkładzie normalnym 5x5,  X=linspace(x1,x2,N) – wektor o wartościach rozłożonych równolegle  X=logspace(x1,x2,N) – wektor o wartościach rozłożonych logarytmicznie
  • 13. Dodatkowe informacje  Macierz odwrotną wyznaczamy poleceniem :  >> D=inv(A)  jej wyznacznik:  >> det(A)  i wartości własne:  >> eig(A)
  • 14. Dodatkowe informacje  >>A=diag(x) - macierz przekątniowa A ze składnikami wektora x na głównej przekątnej  >>x=diag(A) - wektor x utworzony z elementów znajdujących się na głównej przekątnej macierzy A
  • 15. Dodatkowe informacje:  >> A(:,3) - wypisanie trzeciej kolumny macierzy A  >> A(:,2:3) - wypisanie drugiej i trzeciej kolumny macierzy A  >> A(:,2:-1:1) - wypisanie drugiej, a potem pierwszej kol. macierzy A  >> A(:,2:1) - taki zapis daje wektor pusty  >> A(2,:) - wypisanie drugiego wiersza macierzy A  >> A(2:3,:) - wypisanie drugiego i trzeciego wiersza macierzy A  >> A(:) - wszystkie elementy macierzy A jako wektor  >> A(4:8) - elementy macierzy A od czwartego do ósmego  >> A(end,:) - wypisanie ostatniego wiersza macierzy A  >> X=A; X(2;:)=[] - usunięcie drugiego wiersza macierzy X  >> Y=A; Y(1:2:8)=[] - usunięcie sekwencji elementów macierzy Y