SlideShare a Scribd company logo
1 of 18
Primjena računara
Trodimenzionalno crtanje
Naredba plot3
• Matlab posjeduje više različitih naredbi za
  crtanje trodimenzionalnih dijagrama.
• Funkcija plot3 je slična naredbi plot osim što
  prihvata trodimenzionalne podatke.
• Kod ove naredbe pored vektora x i y zadajemo i
  vektor z.
• Vrijednosti x,y i z će potom biti iscrtane u tri
  dimenzije i povezane pravim linijama.
plot3 primjer
clear, clc
x = linspace(0,10*pi,100);
y = cos(x);
z = sin(x);
plot3(x,y,z)
Grid
xlabel(‘ugao’)
ylabel(‘cos(x)’)
zlabel(‘sin(x)’)
title(‘Zavojnica’)
plot3 primjer
t = 0:pi/50:10*pi;
 plot3(sin(t),cos(t),t)
xlabel('sin(t)')
ylabel('cos(t)')
zlabel('t')
grid on
axis
square
plot3 primjer
t=0:pi/50:10*pi;
plot3(t.*sin(t),t.*cos(t),t)

           40


           30


           20


           10


            0
           40
                20                                        40
                     0                               20
                                                 0
                         -20               -20
                               -40   -40
Naredba peaks
• Funkcija peaks predstavlja funkciju dvije
  promjenjljive. Koristi se za demonstraciju
  mogućnosti grafičkih funkcija.
• Pozivanje funkcije peaks sa jednim argumentom
  sa jednim argumentom daće matricu dimenzija
  nxn.
• Povezivanjem naredbe peaks sa naredbama za
  crtanje može dati interesantne rezultate.
Naredba peaks primjer
plot(peaks(100))
          10

           8

           6

           4

           2

           0

          -2

          -4

          -6

          -8
               0   10   20   30   40   50   60   70   80   90   100
Naredba peaks primjer
peaks(100)
                           Peaks




         5



         0




         -5


              2
                                                             3
                                                         2
                  0                                  1
                                                 0
                      -2                -1
                                   -2
                  y        -3
                                             x
Naredba mesh
• Elementarna funkcija za predstavljanje mrežom je
  mesh(z). Nezavisno promjenljive se generišu naredbom:
  meshgrid(xmin:korakx:xmax,ymax:koraky:ymax)
  gdje su sa min i max ozna ene gornje i donje granične
    vrijednosti nezavisno promjenljivih, a sa korak korak
    odabiranja.
• Opšti oblik naredbe mesh(x,y,z,c) crta grafik sa
  koordinatama vektora x i y funkciju z u bojama c.
Naredba mesh primjer
• Nacrtati funkciju z=sin(x2+y2)/(x2+y2) za -pi
  <x,y< pi .
 [x,y]=meshgrid(-pi:pi/10:pi,-pi:pi/10:pi);
 z=sin(x.^2+y.^2+eps)./(x.^2+y.^2+eps);
 mesh(z)
Naredba mesh primjer

         1



       0.5



         0



       -0.5
         30
                                                   25
              20
                                              20
                                         15
                   10               10
                                5
                        0   0
Sedlasta kriva
• Napisati naredbe kojima se iscrtava hiperbolički
  paraboloid (sedlasta površ) z=x2-y2 u granicama
  od -2 do 2 i po x-osi i po y-osi.
 [x,y]=meshgrid(-2:.2:2,-2:.2:2);
 z=x.^2-y.^2;             4


 meshz(z)                 2


                          0


                          -2


                         -4
                         20
                               15                          20
                                    10                15
                                                 10
                                         5   5
Naredba surf
• Za crtanje obojenih površina koriste se funkcije
  surf.
• Najvažnija funkcija ovog oblika je surf čiji je
  opšti oblik surf(x,y,z,c) crta matricu z u funkciji
  x i y u bojama definisanim sa c. Ako se c
  izostavi podrazumjeva se c=z. Funkcija surf(z)
  ima isti oblik kao mesh.
Naredba surf primjer
• Nacrtati sombrero obojenu površinu iz primjera
  sa slajda 10.
 [x,y]=meshgrid(-2:.2:2,-2:.2:2);
 z=x.^2-y.^2;            4


 surf(z)                 2


                         0


                         -2


                         -4
                         30
                                                                    25
                              20
                                                               20
                                                          15
                                    10               10
                                                 5
                                         0   0
Prikazivanje cilindara i sfera
• Za prikazivanje cilindara služi funkcija cylinder.
  Funkcija [x,y,z]=cylinder([R K],n) određuje
  koordinate (ali ne crta) cilindar sa polupre
  čnikom R i sa koeficijentom rasta K u n tačaka.
  Podrazumijevane vrijednosti su su R=1, K=1 i
  n=20. Funkcija cylinder([R K],n) vrši crtanje
  cilindra.
Prikazivanje cilindara i sfera
      [x,y,z]=cylinder([1 1],30);
      surf(x,y,z)
      [x,y,z]=cylinder([1 5],30);
      surf(x,y,z)

 1
                                    1
0.8
                                0.8
0.6
                                0.6
0.4
                                0.4
0.2
                                0.2
 0
 5                                  0
                                    5
                                    1
        0                               0.5                                         1
                         0                                                    0.5
                                              0
                                                                          0
              -5   -5                             -0.5             -0.5
                                                         -1   -1
Prikazivanje cilindara i sfera
• Analogna funkcija postoji za prikazivanje sfera.
• Oblik naredbe [x,y,z]=sphere(n) određuje
  vrijednosti koordinata sfere x, y i z ali ne crta
  sferu.
• Vrijednost n=20 se podrazumjeva. Funkcija
  sphere(n) izvršiti i crtanje sfere.
Prikazivanje cilindara i sfera
 [x,y,z]=sphere(100);
  sphere(100)

                    1


                  0.5


                    0


                  -0.5


                   -1
                    1
                         0.5                                         1
                               0                               0.5
                                                           0
                                   -0.5             -0.5
                                          -1   -1

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
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
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
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...
 

3D plot

  • 2. Naredba plot3 • Matlab posjeduje više različitih naredbi za crtanje trodimenzionalnih dijagrama. • Funkcija plot3 je slična naredbi plot osim što prihvata trodimenzionalne podatke. • Kod ove naredbe pored vektora x i y zadajemo i vektor z. • Vrijednosti x,y i z će potom biti iscrtane u tri dimenzije i povezane pravim linijama.
  • 3. plot3 primjer clear, clc x = linspace(0,10*pi,100); y = cos(x); z = sin(x); plot3(x,y,z) Grid xlabel(‘ugao’) ylabel(‘cos(x)’) zlabel(‘sin(x)’) title(‘Zavojnica’)
  • 4. plot3 primjer t = 0:pi/50:10*pi; plot3(sin(t),cos(t),t) xlabel('sin(t)') ylabel('cos(t)') zlabel('t') grid on axis square
  • 5. plot3 primjer t=0:pi/50:10*pi; plot3(t.*sin(t),t.*cos(t),t) 40 30 20 10 0 40 20 40 0 20 0 -20 -20 -40 -40
  • 6. Naredba peaks • Funkcija peaks predstavlja funkciju dvije promjenjljive. Koristi se za demonstraciju mogućnosti grafičkih funkcija. • Pozivanje funkcije peaks sa jednim argumentom sa jednim argumentom daće matricu dimenzija nxn. • Povezivanjem naredbe peaks sa naredbama za crtanje može dati interesantne rezultate.
  • 7. Naredba peaks primjer plot(peaks(100)) 10 8 6 4 2 0 -2 -4 -6 -8 0 10 20 30 40 50 60 70 80 90 100
  • 8. Naredba peaks primjer peaks(100) Peaks 5 0 -5 2 3 2 0 1 0 -2 -1 -2 y -3 x
  • 9. Naredba mesh • Elementarna funkcija za predstavljanje mrežom je mesh(z). Nezavisno promjenljive se generišu naredbom: meshgrid(xmin:korakx:xmax,ymax:koraky:ymax) gdje su sa min i max ozna ene gornje i donje granične vrijednosti nezavisno promjenljivih, a sa korak korak odabiranja. • Opšti oblik naredbe mesh(x,y,z,c) crta grafik sa koordinatama vektora x i y funkciju z u bojama c.
  • 10. Naredba mesh primjer • Nacrtati funkciju z=sin(x2+y2)/(x2+y2) za -pi <x,y< pi . [x,y]=meshgrid(-pi:pi/10:pi,-pi:pi/10:pi); z=sin(x.^2+y.^2+eps)./(x.^2+y.^2+eps); mesh(z)
  • 11. Naredba mesh primjer 1 0.5 0 -0.5 30 25 20 20 15 10 10 5 0 0
  • 12. Sedlasta kriva • Napisati naredbe kojima se iscrtava hiperbolički paraboloid (sedlasta površ) z=x2-y2 u granicama od -2 do 2 i po x-osi i po y-osi. [x,y]=meshgrid(-2:.2:2,-2:.2:2); z=x.^2-y.^2; 4 meshz(z) 2 0 -2 -4 20 15 20 10 15 10 5 5
  • 13. Naredba surf • Za crtanje obojenih površina koriste se funkcije surf. • Najvažnija funkcija ovog oblika je surf čiji je opšti oblik surf(x,y,z,c) crta matricu z u funkciji x i y u bojama definisanim sa c. Ako se c izostavi podrazumjeva se c=z. Funkcija surf(z) ima isti oblik kao mesh.
  • 14. Naredba surf primjer • Nacrtati sombrero obojenu površinu iz primjera sa slajda 10. [x,y]=meshgrid(-2:.2:2,-2:.2:2); z=x.^2-y.^2; 4 surf(z) 2 0 -2 -4 30 25 20 20 15 10 10 5 0 0
  • 15. Prikazivanje cilindara i sfera • Za prikazivanje cilindara služi funkcija cylinder. Funkcija [x,y,z]=cylinder([R K],n) određuje koordinate (ali ne crta) cilindar sa polupre čnikom R i sa koeficijentom rasta K u n tačaka. Podrazumijevane vrijednosti su su R=1, K=1 i n=20. Funkcija cylinder([R K],n) vrši crtanje cilindra.
  • 16. Prikazivanje cilindara i sfera [x,y,z]=cylinder([1 1],30); surf(x,y,z) [x,y,z]=cylinder([1 5],30); surf(x,y,z) 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 5 0 5 1 0 0.5 1 0 0.5 0 0 -5 -5 -0.5 -0.5 -1 -1
  • 17. Prikazivanje cilindara i sfera • Analogna funkcija postoji za prikazivanje sfera. • Oblik naredbe [x,y,z]=sphere(n) određuje vrijednosti koordinata sfere x, y i z ali ne crta sferu. • Vrijednost n=20 se podrazumjeva. Funkcija sphere(n) izvršiti i crtanje sfere.
  • 18. Prikazivanje cilindara i sfera [x,y,z]=sphere(100); sphere(100) 1 0.5 0 -0.5 -1 1 0.5 1 0 0.5 0 -0.5 -0.5 -1 -1