Hakunin

Mata2_Vezba3

Apr 11th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.30 KB | None | 0 0
  1. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  2.  
  3. >> subplot(3,2,3) %tri puta dva grafika, crta se u trecem grafiku
  4.  
  5. >> x=0:0.1:10*pi;
  6. >> y=cos(x);
  7. >> z=sin(x);
  8. >> plot3(x,y,z)    %plot3 = naredba za linijske grafike
  9. >> title('3D-Grafika')
  10. >> xlabel('x-osa')
  11. >> ylabel('y-osa')
  12. >> zlabel('z-osa')
  13. >> comet3(x,y,z)  % iscrtava putanju grafika
  14.  
  15. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  16.  
  17. >> y=cos(t).*sin(t); %mnozenje svakog clana pojedinacno
  18.  
  19. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  20.  
  21. >> x=-3:3
  22.  
  23. x =
  24.  
  25.     -3    -2    -1     0     1     2     3
  26.  
  27. >> y=-2:2
  28.  
  29. y =
  30.  
  31.     -2    -1     0     1     2
  32.  
  33. >> [X,Y]=meshgrid(x,y)
  34.  
  35. X =
  36.  
  37.     -3    -2    -1     0     1     2     3
  38.     -3    -2    -1     0     1     2     3
  39.     -3    -2    -1     0     1     2     3
  40.     -3    -2    -1     0     1     2     3
  41.     -3    -2    -1     0     1     2     3
  42.  
  43.  
  44. Y =
  45.  
  46.     -2    -2    -2    -2    -2    -2    -2
  47.     -1    -1    -1    -1    -1    -1    -1
  48.      0     0     0     0     0     0     0
  49.      1     1     1     1     1     1     1
  50.      2     2     2     2     2     2     2
  51.  
  52. >> Z=X.^2-Y.^2
  53.  
  54. Z =
  55.  
  56.      5     0    -3    -4    -3     0     5
  57.      8     3     0    -1     0     3     8
  58.      9     4     1     0     1     4     9
  59.      8     3     0    -1     0     3     8
  60.      5     0    -3    -4    -3     0     5
  61.  
  62. >> mesh(Z)
  63. >> surf(Z)
  64.  
  65. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  66.  
  67. >> y=-3:0.2:3;
  68. >> y=-2:0.2:2;
  69. >> [X,Y]=meshgrid(x,y);
  70. >> Z=2-(X.^2+Y.^2);
  71. >> mesh(Z)
  72. >> meshc(Z)
  73. >> meshz(Z)
  74. >> colormap(cool)
  75. >> waterfall(Z)
  76.  
  77. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  78.  
  79. >> x=0:0.1:10*pi;
  80. >> y=0:0.1:10*pi;
  81. >> [X,Y]=meshgrid(x,y);
  82. >> Z=3*sin(X)+cos(Y);
  83. >> subplot(2,3,1),mesh(Z),title('mesh')
  84. >> subplot(2,3,2),meshc(Z),title('meshc')
  85. >> subplot(2,3,3),meshz(Z),title('meshz')
  86. >> subplot(2,3,4),surf(Z),title('surf')
  87. >> subplot(2,3,5),surfc(Z),title('surfc')
  88. >> subplot(2,3,5),waterfall(Z),title('waterfall')
  89. >> subplot(2,3,5),surfc(Z),title('surfc')
  90. >> subplot(2,3,6),waterfall(Z),title('waterfall')
  91.  
  92. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  93.  
  94. >> surf(peaks(20))
  95. >> surf(peaks(50))  %veca rezolucija
  96. >> surf(peaks(500)) %nista se ne vidi
  97. >> surf(peaks(50))
  98. >> contour(peaks(20)) %vide se samo konture iz pticije perspektive
  99. >> contour(peaks(20),5)
  100. >> contour(peaks(20),15) %veci broj kontura
  101. >> contour3(peaks(20),15) %3D konture
  102. >> contour3(peaks(20),50)
  103.  
  104. >> sphere(10) %lopta
  105. >> sphere(100)
  106.  
  107. >> cylinder(2)
  108. >> cylinder(20) %menja se poluprecnik a ne rezolucija
  109. >> cylinder(20,5)
  110. >> cylinder(20,50) %menja se rezolucija sa drugim brojem
  111. >> cylinder([20,30],50) %gornji i donji poluprecnik
  112.  
  113. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Add Comment
Please, Sign In to add comment