+ All Categories
Home > Documents > Proiect Matlab

Proiect Matlab

Date post: 04-Apr-2015
Category:
Upload: drackmic
View: 944 times
Download: 5 times
Share this document with a friend
85
Universitatea “Vasile Alecsandri” din Bacau Facultatea de Stiinte Specializarea Informatica, an II, grupa 421 Matrix Laboratory Geometrie computationala Proiect MATLAB Realizat de: HALÎNGA VICTORIA Îndrumator: COSMIN ION TOMOZEI Anul 2010
Transcript
Page 1: Proiect Matlab

Universitatea “Vasile Alecsandri” din Bacau

Facultatea de Stiinte

Specializarea Informatica, an II, grupa 421

Matrix Laboratory Geometrie computationala

Proiect MATLAB

Realizat de: HALÎNGA VICTORIA

Îndrumator: COSMIN ION TOMOZEI

Anul 2010

Page 2: Proiect Matlab

Geometrie computationala

- 2 -

Capitolul I

Calcule matematice

1. >> (1+sqrt(5))/2

ans =

1.6180

Exemplu personal 2. >> (10-sqrt(49))*2

ans =

6

Exemplu personal 3. >> (3-sqrt(49))*2

ans =

-8

Calcule simple in MATLAB. Vectori si matrice.

1. >> a =5; >> b=12;

>> a+b

ans =

17

Exemplu personal

2. >> a=32; >> b=8;

>> (a+b)-b

ans =

32

Page 3: Proiect Matlab

Geometrie computationala

- 3 -

Exemplu personal

3. >> a1=5; >> a2=18;

>> a2-a1

ans =

13

4. >> x=sin(2)

x =

0.9093

5. >> y=3*exp(x)+cos(x); -- daca folosim semnul ; dupa tastarea expresiei nu se va afisa

>> -- variabila de iesire

6. >> y=3*exp(x)+cos(x)

y =

8.0620

Exemplu personal

7. >> x=sin(pi)

x =

1.2246e-016

Exemplu personal

8. >> x=sin(pi/2)

x =

1

Page 4: Proiect Matlab

Geometrie computationala

- 4 -

Exemplu personal

9. >> cos(pi/2)

ans =

6.1232e-017

Exemplu personal

10. >> cos(2*pi)

ans =

1

11. >> x=sin(22), y=exp(3)

x =

-0.0089

y =

20.0855

Exemplu personal

12. >> x=sin(1), y=cos(1)

x =

0.8415

y =

0.5403

13. >> (-1)^0.25

ans =

0.7071 + 0.7071i

Page 5: Proiect Matlab

Geometrie computationala

- 5 -

14. >> 2-3i

ans =

2.0000 - 3.0000i

Exemplu personal

15. >> 12-4i

ans =

12.0000 - 4.0000i

Exemplu personal

16. >> 1^0.25

ans =

1

Exemplu personal

17. >> (-1)^0.12

ans =

0.9298 + 0.3681i

18. >> x=[1 2 3 4 5] ; -- pentru memorarea unui sir de numere

{1,2,3,4,5} intr-un vector

>>

19. >> A=[2 -1 ;0 3] -- afisarea elementelor unei matrici A

A =

2 -1

0 3

Page 6: Proiect Matlab

Geometrie computationala

- 6 -

20. >> x=[1 2 3 4 5] ; >> x(4)

ans =

4

21. >> A=[2 -1 ;0 3] ; >> A(1,2)

ans =

-1

22. >> A=[2 -1 ;0 3] , A(1,2)

A =

2 -1

0 3

ans =

-1

23. >> linspace(0, 1, 7)

ans =

0 0.1667 0.3333 0.5000 0.6667

0.8333 1.0000

Exemplu personal

24. >> linspace(-2, 2, 5)

ans =

-2 -1 0 1 2

Page 7: Proiect Matlab

Geometrie computationala

- 7 -

Exemplu personal

25. >> x=[1 2 3 4 5] ; -- lungimea unui vector

>> length(x)

ans =

5

Exemplu personal

26. >> A=[2 -1 ;0 3] ; -- dimensiunea unei matrici

>> size(A)

ans =

2 2

27. >> A=[1 2 3 ; 3 4 -1;2 1 1;4 3 1]; >> A(:,2)

ans =

2

4

1

3

28. >> A=[1 2 3 ; 3 4 -1;2 1 1;4 3 1], A(1,:)

A =

1 2 3

3 4 -1

2 1 1

4 3 1

ans =

1 2 3

Page 8: Proiect Matlab

Geometrie computationala

- 8 -

29. >> A=[1 2 3 ; 3 4 -1;2 1 1;4 3 1], A(:,3)

A =

1 2 3

3 4 -1

2 1 1

4 3 1

ans =

3

-1

1

1

Exemplu personal

30. >> A=[1 2 3 ; 3 4 -1;2 1 1;4 3 1], A(:)

A =

1 2 3

3 4 -1

2 1 1

4 3 1

ans =

1

3

2

4

2

4

1

3

3

-1

1

1

31. >> A = [1 2 3;4 5 6;7 8 9]; >> B = [1 1 1;2 2 2;3 3 3];

Page 9: Proiect Matlab

Geometrie computationala

- 9 -

>> C = [1 2;3 4;5 6];

>> A+B

ans =

2 3 4

6 7 8

10 11 12

>> A+C

??? Error using ==> plus

Matrix dimensions must agree.

32. >> A=[1 2 3;3 5 6; 34 5 6]

A =

1 2 3

3 5 6

34 5 6

>> C*A

??? Error using ==> mtimes

Inner matrix dimensions must agree.

>> A*C

ans =

22 28

48 62

79 124

33. >> v = [0:2:8]

v =

0 2 4 6 8

>> A = [ 1 2 3; 3 4 5; 6 7 8]

A =

1 2 3

3 4 5

6 7 8

Page 10: Proiect Matlab

Geometrie computationala

- 10 -

>> A*v(1:3)

??? Error using ==> mtimes

Inner matrix dimensions must agree.

>> v(1:3)

ans =

0 2 4

>> A*v(1:3)'

ans =

16

28

46

>> v(1:3)'

ans =

0

2

4

Exemplu personal

34. >> A=[2 4 6; 2 4 6;1 3 6]

A =

2 4 6

2 4 6

1 3 6

>> B=[1 6 3; 6 4 2; 2 2 2]

B =

1 6 3

6 4 2

2 2 2

>> C=[1 1 1; 2 2 2]

Page 11: Proiect Matlab

Geometrie computationala

- 11 -

C =

1 1 1

2 2 2

>> A+B

ans =

3 10 9

8 8 8

3 5 8

>> B+A

ans =

3 10 9

8 8 8

3 5 8

>> A*B

ans =

38 40 26

38 40 26

31 30 21

>> B*A

ans =

17 37 60

22 46 72

10 22 36

>> A*C

??? Error using ==> mtimes

Inner matrix dimensions must agree.

Page 12: Proiect Matlab

Geometrie computationala

- 12 -

>> C*A

ans =

5 11 18

10 22 36

>> B*C

??? Error using ==> mtimes

Inner matrix dimensions must agree.

>> C*B

ans =

9 12 7

18 24 14

- f(x) = x

- g(x) = x

35. >> x=linspace(-1,1,20); >> f=1./(1+x.^2).*exp(x-1); >> x=linspace(0,2*pi,20);

>> g=cos(x).^2.*exp(x);

>> x=linspace(-1,1,20);

>> f=1./(1+x.^2).*exp(x-1)

f =

Columns 1 through 7

0.0677 0.0835 0.1029 0.1264 0.1544 0.1871

0.2241

Columns 8 through 14

0.2644 0.3065 0.3481 0.3867 0.4203 0.4476

0.4682

Page 13: Proiect Matlab

Geometrie computationala

- 13 -

Columns 15 through 20

0.4825 0.4916 0.4967 0.4991 0.4999 0.5000

>> x=linspace(0,2*pi,20);

>> g=cos(x).^2.*exp(x)

g =

Columns 1 through 7

1.0000 1.2452 1.2066 0.8068 0.2262 0.0356

1.1736

Columns 8 through 14

4.6437 10.8992 19.0827 26.5618 29.3934 24.2639

11.8805

Columns 15 through 20

0.6989 8.5967 59.4004 172.1172 344.1507 535.4917

36. >> u=[2 3 4 1.2 5 -1]; -- inmultirea a doi vectori linie de aceeasi dimensiune

>> v=[-1 3 4 -3 0 1];

>> u.*v

ans =

-2.0000 9.0000 16.0000 -3.6000 0 -1.0000

>> u*v

??? Error using ==> mtimes

Inner matrix dimensions must agree.

>> v'

ans =

-1

3

4

-3

0

1

Page 14: Proiect Matlab

Geometrie computationala

- 14 -

37. >> u*v' -- produsul scalar a vectorilor u si v

ans =

18.4000

>> C=[1 3;4 67;12 45]

C =

1 3

4 67

12 45

>> C^2

??? Error using ==> mpower

Matrix must be square.

38. >> C=[1 2 3; 1 2 3; 1 2 3]

C =

1 2 3

1 2 3

1 2 3

>> C^2 --ridicarea la putere a unei matrici

ans =

6 12 18

6 12 18

6 12 18

39. >> A=[2 -1 ;0 3] ;

>> A^-1 -- inversa unei matrici

ans =

0.5000 0.1667

0 0.3333

Page 15: Proiect Matlab

Geometrie computationala

- 15 -

40. >> A=[1 2 3 ; 3 4 -1;2 1 1;4 3 1]; >> A^-1

??? Error using ==> mpower

Matrix must be square.

41. >> A=[1 2 3;3 5 6; 34 5 6]; >> A^-1

ans =

0.0000 -0.0323 0.0323

-2.0000 1.0323 -0.0323

1.6667 -0.6774 0.0108

42. >> A=[1 2 3;3 5 6; 34 5 6]; >> B=[1 5 7];

>> X=A/B

X =

0.4267

0.9333

1.3467

43. >> A=[16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1];

>> X=inv(A) -- inversa unei matrici

Warning: Matrix is close to singular or badly scaled.

Results may be inaccurate. RCOND = 9.796086e-018.

X =

1.0e+015 *

0.1251 0.3753 -0.3753 -0.1251

-0.3753 -1.1259 1.1259 0.3753

0.3753 1.1259 -1.1259 -0.3753

-0.1251 -0.3753 0.3753 0.1251

44. >> x = (-5:.1:5); >> y = x./(1+x.^2);

>> y = x./(1+x.^2)

Page 16: Proiect Matlab

Geometrie computationala

- 16 -

y =

Columns 1 through 7

-0.1923 -0.1959 -0.1997 -0.2036 -0.2076 -0.2118

-0.2161

Columns 8 through 14

-0.2206 -0.2253 -0.2302 -0.2353 -0.2406 -0.2461

-0.2519

Columns 15 through 21

-0.2579 -0.2642 -0.2707 -0.2775 -0.2847 -0.2922

-0.3000

Columns 22 through 28

-0.3082 -0.3167 -0.3257 -0.3351 -0.3448 -0.3550

-0.3657

Columns 29 through 35

-0.3767 -0.3882 -0.4000 -0.4121 -0.4245 -0.4370

-0.4494

Columns 36 through 42

-0.4615 -0.4730 -0.4833 -0.4918 -0.4977 -0.5000

-0.4972

Columns 43 through 49

-0.4878 -0.4698 -0.4412 -0.4000 -0.3448 -0.2752

-0.1923

Columns 50 through 56

-0.0990 0 0.0990 0.1923 0.2752 0.3448

0.4000

Columns 57 through 63

0.4412 0.4698 0.4878 0.4972 0.5000 0.4977

0.4918

Page 17: Proiect Matlab

Geometrie computationala

- 17 -

Columns 64 through 70

0.4833 0.4730 0.4615 0.4494 0.4370 0.4245

0.4121

Columns 71 through 77

0.4000 0.3882 0.3767 0.3657 0.3550 0.3448

0.3351

Columns 78 through 84

0.3257 0.3167 0.3082 0.3000 0.2922 0.2847

0.2775

Columns 85 through 91

0.2707 0.2642 0.2579 0.2519 0.2461 0.2406

0.2353

Columns 92 through 98

0.2302 0.2253 0.2206 0.2161 0.2118 0.2076

0.2036

Columns 99 through 101

0.1997 0.1959 0.1923

45. >> x=1:.5:4; >> y=1:7;

>> x./y

ans =

1.0000 0.7500 0.6667 0.6250 0.6000 0.5833

0.5714

46. >> x=1:.5:4; >> y=1:6;

>> x./y

??? Error using ==> rdivide

Matrix dimensions must agree

Page 18: Proiect Matlab

Geometrie computationala

- 18 -

47. >> A=[1 2 3; 45 6 7; 12 3 4;1 1 1]

A =

1 2 3

45 6 7

12 3 4

1 1 1

>> A.^2

ans =

1 4 9

2025 36 49

144 9 16

1 1 1

>> A^2

??? Error using ==> mpower

Matrix must be square.

48. >> A=[1 2 3; 45 6 7; 12 3 4]; >> B=A/4

B =

0.2500 0.5000 0.7500

11.2500 1.5000 1.7500

3.0000 0.7500 1.0000

49. >> A=[1 2 3; 45 6 7; 12 3 4]

A =

1 2 3

45 6 7

12 3 4

Page 19: Proiect Matlab

Geometrie computationala

- 19 -

>> A' -- transpusa unei matrici

ans =

1 45 12

2 6 3

3 7 4

Exemplu personal

50. >> x=0:4; >> y=5:5:25;

>> A=[x', y']

A =

0 5

1 10

2 15

3 20

4 25

Exemplu personal

51. >> B=zeros(2,2)

B =

0 0

0 0

Exemplu personal

52. >> B=ones(2,3)

B =

1 1 1

1 1 1

Exemplu personal

53. >> B=eye(3)

B =

1 0 0

0 1 0

0 0 1

Page 20: Proiect Matlab

Geometrie computationala

- 20 -

Exemplu personal

54. >> x=0:3; >> B=diag(x)

B =

0 0 0 0

0 1 0 0

0 0 2 0

0 0 0 3

Exemplu personal

55. >> A=[1 2 3; 45 6 7; 12 3 4;1 1 1]

A =

1 2 3

45 6 7

12 3 4

1 1 1

>> x=max(A)

x =

45 6 7

>> x=min(A)

x =

1 1 1

>> rank(A)

ans =

3

>> B=abs(A)

B =

1 2 3

45 6 7

12 3 4

1 1 1

Page 21: Proiect Matlab

Geometrie computationala

- 21 -

Exemplu personal

56. >> zeros(1,2)

ans =

0 0

>> zeros(2,1)

ans =

0

0

>> ones(1,2)

ans =

1 1

>> ones(2,1)

ans =

1

1

57. >> B = [ [1 2 3]' [2 4 7]' [3 5 8]']

B =

1 2 3

2 4 5

3 7 8

58. >> A=[1 2 3; 45 6 7; 12 3 4]; >> B=[1 2 3; 2 4 7; 3 5 8];

>> C=A.*B

C =

1 4 9

90 24 49

36 15 32

Page 22: Proiect Matlab

Geometrie computationala

- 22 -

>> C=A./B

C =

1.0000 1.0000 1.0000

22.5000 1.5000 1.0000

4.0000 0.6000 0.5000

59. >> sqrt([1 2 4 6])

ans =

1.0000 1.4142 2.0000 2.4495

60. >> sin([pi/4 pi/2 pi])

ans =

0.7071 1.0000 0.0000

61. >> x=linspace(0, 1, 7)

x =

0 0.1667 0.3333 0.5000 0.6667 0.8333

1.0000

Exemplu personal

62. >> x=0:4; >> min(x)

ans =

0

>> max(x)

ans =

4

Page 23: Proiect Matlab

Geometrie computationala

- 23 -

Exemplu personal

63. >> x=[4, 3 , 7, 1]

x =

4 3 7 1

>> min(x)

ans =

1

>> max(x)

ans =

7

>> sort(x)

ans =

1 3 4 7

>> sum(x)

ans =

15

64. >> x=linspace(0, 1, 7)

x =

0 0.1667 0.3333 0.5000 0.6667 0.8333

1.0000

>> [min(x) max(x)]

ans =

0 1

Page 24: Proiect Matlab

Geometrie computationala

- 24 -

>> sort(x)

ans =

0 0.1667 0.3333 0.5000 0.6667 0.8333

1.0000

65. >> sum(x)

ans =

3.5000

>> rand

ans =

0.8147

>> rand(3)

ans =

0.9058 0.6324 0.5469

0.1270 0.0975 0.9575

0.9134 0.2785 0.9649

Exemplu personal

66. >> A=[1 2 3; 45 6 7; 12 3 4]; >> triu(A)

ans =

1 2 3

0 6 7

0 0 4

>> tril(A)

ans =

1 0 0

45 6 0

12 3 4

Page 25: Proiect Matlab

Geometrie computationala

- 25 -

>> min(A)

ans =

1 2 3

>> max(A)

ans =

45 6 7

>> sum(A)

ans =

58 11 14

67. >> x=sin(1)+sin(2)+... sin(3)+sin(4)

x =

1.1351

68. >> x=[1 2 3]

x =

1 2 3

>> y=[1 0 0]

y =

1 0 0

>> x>0 & y>0

ans =

1 0 0

69. >> x=[1 2 3]; >> y=[1 0 0];

Page 26: Proiect Matlab

Geometrie computationala

- 26 -

>> x>0 |y>0

ans =

1 1 1

Reprezentarea grafica a curbelor si suprafetelor

Reprezentarea 2D

1. >> y = (-5:0.1:4).^3; >> plot(y);

2. >> x = -5:0.1:4; >> y=x.^3;

>> plot(x, y);

>> title('graficul functiei x^3')

Page 27: Proiect Matlab

Geometrie computationala

- 27 -

Exemplu personal

3. >> x=pi:.5:2*pi; >> y=sin(x);

>> z=cos(x);

>> plot(x,y, '*g')

Exemplu personal

4. >> x=pi:.1:2*pi; >> y=sin(x);

>> z=cos(x);

>> plot(x,y, '*g')

>> title('Graficul functiilor trigonometrice')

>> xlabel('x')

>> ylabel('y')

Page 28: Proiect Matlab

Geometrie computationala

- 28 -

5. >> x=[-pi:.3:pi]; >> y=sin(x);

>> z=cos(x);

>> plot(x,y,'-r');

>> hold on

>> plot(x,z,'--g');

>> hold on

>> plot(x,0,'*-b')

>> legend ('-sin(x)','-cos(x)','y=0');

Page 29: Proiect Matlab

Geometrie computationala

- 29 -

Exemplu personal

6. >> x=[-pi./2:.2:pi./2]; >> y=sin(x);

>> z=cos(x);

>> plot(x,y,'--g');

>> hold on

>> plot(x,z,'-r');

>> hold on

>> plot(y,z,'*b')

>> legend ('-sin(x)','-cos(x)','x=0')

7. >> x=[-2:.2:2]; >> y=exp(-x.^2);

>> subplot (2,2,1);

>> plot (x,y);

>> title ('exp(-x^2)');

>> z=exp(-x.^2).*cos(2*pi*x);

>> subplot (2,2,2);

>> plot (x,z);

>> title ('exp(-x^2)*cos(2*pi*x)');

>> t=exp(-x.^2).*cos(4*pi*x);

>> subplot (2,2,3);

>> plot (x,t);

>> title ('exp(-x^2)*cos(4*pi*x)');

Page 30: Proiect Matlab

Geometrie computationala

- 30 -

Exemplu personal

8. >> x=[-3:.2:3]; >> y=exp(x.^2);

>> subplot (3,3,1);

>> plot (x,y);

>> title ('exp(x^2)');

>> subplot (3,3,2);

>> z=exp(-x.^2);

>> plot(x,z);

>> title ('exp(-x^2)');

>> z=exp(x.^2).*cos(3*pi*x);

>> subplot(3,3,3);

>> plot(x,z);

>> title ('exp(x^2)*cos(3*pi*x)');

9. >> fplot ('exp(-t^2)',[-2 2]) >> hold on

>> fplot('2*exp(-t^2)',[-2 2])

>> fplot('3*exp(-t^2)',[-2 2])

>> hold off

Page 31: Proiect Matlab

Geometrie computationala

- 31 -

Exemplu personal

10. >> fplot ('exp(-t^2)',[-3 3]) >> hold on

>> fplot ('3*exp(-t^2)',[-3 3])

>> fplot ('4*exp(-t^2)',[-3 3])

>> hold off

Page 32: Proiect Matlab

Geometrie computationala

- 32 -

Reprezentarea 3D. Suprafete.

11. >> x=[-6:.5:6]; >> y=x;

>> [X,Y]=meshgrid(x);

>> Z=sqrt(X.^2+Y.^2);

>> mesh(X,Y,Z)

Exemplu personal

12. >> x=[-8:.5:8]; >> y=x;

>> [X,Y]=meshgrid(x);

>> Z=sqrt(X.^2+Y.^2);

>> surf(X,Y,Z)

Page 33: Proiect Matlab

Geometrie computationala

- 33 -

13. >> [x,y] = meshgrid([-2:.2:2]); >> Z=x.^2*exp(-x.^2-y.^2);

>> mesh(x,y,Z);

>> colormap cool;

Exemplu personal

14. >> [x,y] = meshgrid([-3:.2:3]); >> Z=x.^2*exp(-2.*x.^2-y.^2);

>> mesh(x,y,Z);

>> colormap spring;

Page 34: Proiect Matlab

Geometrie computationala

- 34 -

15. >> Z=peaks(30); >> subplot(2,2,1);

>> surf(Z);

>> shading flat;

>> title (' Flat shading!')

>> Z=peaks(30);

>> subplot(2,2,2);

>> surf(Z);

>> shading interp;

>> title (' Interpolated shading!')

>> colormap summer;

>> Z=peaks(30);

>> subplot(2,2,3);

>> surf(Z);

>> shading faceted;

>> title (' Faceted shading!')

>> colormap summer;

Exemplu personal

16. >> Z=peaks(50); >> surf(Z);

>> shading faceted;

>> title (' Faceted shading!')

>> colormap bone;

Page 35: Proiect Matlab

Geometrie computationala

- 35 -

17. >> x=linspace(0,pi,20); >> y=linspace(-pi,pi,20);

>> [xx,yy]=meshgrid(x,y);

>> zz=func(xx,yy);

>> mesh(xx,yy,zz)

Page 36: Proiect Matlab

Geometrie computationala

- 36 -

18. >> x=linspace(0,2*pi,20); >> y=linspace(-pi,pi,20);

>> [xx,yy]=meshgrid(x,y);

>> zz=func(xx,yy);

>> surf(xx, yy, zz)

19. >> x=0:.1:pi; >> y=0:.1:pi;

>> [X,Y]=meshgrid(x,y);

>> Z=sin(Y.^2+X)-cos(Y-X.^2);

>> subplot(2,2,1);

>> surf(Z)

>> title('surf');

>> subplot(2,2,2);

>> surfc(Z);

>> title('surfc');

>> subplot(2,2,3);

>> mesh(Z);

>> title('mesh');

Page 37: Proiect Matlab

Geometrie computationala

- 37 -

Exemplu personal

20. >> Z=peaks(40); >> surfc(Z)

>> title('surfc');

>> colormap hot;

21. >> [X,Y] = meshgrid(0:.1:2*pi,-pi:.1:0);

>> Z = sin(X).*cos(Y);

>> meshz(X,Y,Z);

>> axis('equal');

Page 38: Proiect Matlab

Geometrie computationala

- 38 -

Exemplu personal

22. >> [X,Y] = meshgrid(0:.1:2*pi,-pi:.1:0); >> Z = cos(X).*sin(Y);

>> meshz(X,Y,Z);

>> axis('equal');

>> title('meshz');

Page 39: Proiect Matlab

Geometrie computationala

- 39 -

23. >> [th,r]=meshgrid(0:pi/40:2*pi,0:0.05:1); >> [X,Y]=pol2cart(th,r);

>> g=inline('r.^n.*sin(n*th)','r','th','n')

g =

Inline function:

g(r,th,n) = r.^n.*sin(n*th)

>> surf(X,Y,g(r,th,5))

>> hold on

>> mesh(X,Y,-ones(size(X)))

Exemplu personal

24. >> [th,r]=meshgrid(0:pi/40:2*pi,0:0.05:1); >> [X,Y]=pol2cart(th,r);

>> surf(X,Y,g(r,th,3))

>> colormap winter;

>> hold on

>> mesh(X,Y,-zeros(size(X)))

Page 40: Proiect Matlab

Geometrie computationala

- 40 -

25. >> x=-3*pi:.25:3*pi; >> A=linspace(3,0);

>> A=exp(-A);

>> X=sin(x).^2./(x+eps).^2;

>> Y=A'*X;

>> waterfall(Y)

Exemplu personal

26. >> x=-3*pi:.25:3*pi; >> A=linspace(3,0);

>> Y=A'*X;

>> X=cos(x).^2./(x+eps).^2;

>> waterfall(Y)

Page 41: Proiect Matlab

Geometrie computationala

- 41 -

Exemplu personal

27. >> x=-3*pi:.25:3*pi; >> A=linspace(3,0);

>> A=exp(-A);

>> X=cos(x).^2./(x+eps).^2;

>> Y=A'*X;

>> waterfall(Y)

Page 42: Proiect Matlab

Geometrie computationala

- 42 -

28. >> x=0:0.5:6; >> t=0:0.5:20;

>> [X,T]=meshgrid(x,t)

>> g=inline('cos(x-0.4*y).*exp(-0.4*x)','x','y')

g =

Inline function:

g(x,y) = cos(x-0.4*y).*exp(-0.4*x)

>> contour(X,T,g(X,T))

>> pcolor(X,T,g(X,T))

>> hold on

>> contour(X,T,g(X,T),'k')

>> shading interp

>> colorbar

29. >> x=0:0.5:6;

>> t=0:0.5:20;

>> [X,T]=meshgrid(x,t);

>> g=inline('cos(x-0.4*y).*exp(-0.4*x)','x','y')

g =

Inline function:

g(x,y) = cos(x-0.4*y).*exp(-0.4*x)

>> surfc(X,T,g(X,T))

>> colormap(bone)

Page 43: Proiect Matlab

Geometrie computationala

- 43 -

30. >> [X,Y]=meshgrid(-2:.1:2,-2:.2:2); >> f=-X.*Y.*exp(-2*(X.^2+Y.^2));

>> mesh(X,Y,f);

>> xlabel('x');

>> ylabel('y');

>> grid on;

>> contour(X,Y,f)

>> xlabel('x');

>> ylabel('y');

>> grid on;

>> hold on

>> fmax=max(max(f))

fmax =

0.0886

>> kmax=find(f==fmax)

kmax =

329

533

>> pos=[X(kmax),Y(kmax)]

pos =

-0.5000 0.6000

0.5000 -0.6000

Page 44: Proiect Matlab

Geometrie computationala

- 44 -

>> plot(X(kmax),Y(kmax),'*')

>> text(X(kmax),Y(kmax),' maximul')

31. >> [x,y]=meshgrid(-3:0.1:3,-5:0.1:10); >> f=100*(y-x.^2).^2+(1-x).^2+2;

>> mesh(x,y,f);

>> xlabel('x')

>> ylabel('y')

>> zlabel('z')

Page 45: Proiect Matlab

Geometrie computationala

- 45 -

Exemplu personal

32. >> sphere (40)

33. >> [x,y,z]=ellipsoid(2,0,2,2,1,1); >> surf(x,y,z);

>> axis([0 4 -2 2 0 4]);

>> hold on

>> contour(x,y,z)

Page 46: Proiect Matlab

Geometrie computationala

- 46 -

34. >> x = linspace(-3*pi,3*pi,50); >> r = cos(x).* sin(0.5*x).*exp((x.^2)/200);

>> r = r - min(r);

>> plot(r,linspace(0,1,length(r)));

>> ylabel('z')

>> cylinder(r)

35. >> t=[-1:.01:1];

>> [x,y,z]=cylinder(2+cos(t));

>> mesh(x,y,z)

>> axis square

>> colormap autumn

Page 47: Proiect Matlab

Geometrie computationala

- 47 -

36. >> t = 0:0.1:10*pi; >> x = exp(-t/20).*cos(t);

>> y = exp(-t/20).*sin(t);

>> z = t;

>> plot3(x,y,z);

>> xlabel('x');

>> ylabel('y');

>> zlabel('z');

Page 48: Proiect Matlab

Geometrie computationala

- 48 -

37. >> theta = 0:.2:2*pi; >> x=sin(theta);

>> y=cos(theta);

>> z=sin(theta);

>> stem3(x,y,z);

>> hold on

>> plot3(x,y,z,'r')

>> plot(x,y)

38. >> subplot(2,2,1);plot3(x,y,z); >> view(-10,10);

>> title('Default plot3');

>> subplot(2,2,2);plot3(x,y,z,'og');

>> view(-9,56);

>> title('Az=-10, El=10');

>> subplot(2,2,3);plot3(x,y,z,'xb');

>> view(0,90);

>> title('Az=0, El=90');

>> subplot(2,2,4);plot3(x,y,z,'dr');

>> view(90,0);

>> title('Az=90, El=0');

Page 49: Proiect Matlab

Geometrie computationala

- 49 -

39. >> t = 0:0.1:10*pi; >> x = exp(-t/20).*cos(t);

>> y = exp(-t/20).*sin(t);

>> z = t;

>> plot3(x,y,z);

>> xlabel('x');

>> ylabel('y');

>> zlabel('z');

>> subplot(2,2,1);plot3(x,y,z);

>> view(-10,10);

>> title('Default plot3');

>> subplot(2,2,2);plot3(x,y,z,'og');

>> view(-9,56);

>> title('Az=-10, El=10');

>> subplot(2,2,3);plot3(x,y,z,'xb');

>> view(0,90);

>> title('Az=0, El=90');

>> subplot(2,2,4);plot3(x,y,z,'dr');

>> view(90,0);

>> title('Az=90, El=0');

Page 50: Proiect Matlab

Geometrie computationala

- 50 -

Grafice de suprafete cu iluminari.

1. >> [X,Y] = meshgrid(-8:.5:8);

>> R = sqrt(X.^2 + Y.^2) + eps;

>> Z = sin(R)./R;

>> surf(X,Y,Z)

>> surf(X,Y,Z,'FaceColor','red','EdgeColor','none');

>> camlight left; lighting phong;

Page 51: Proiect Matlab

Geometrie computationala

- 51 -

Exemplu personal 2. >> [X,Y] = meshgrid(-8:.5:8);

>> R = sqrt(X.^2 + Y.^2) + eps;

>> Z = sin(R)./R;

>> subplot(2,2,1);

>> surf(X,Y,Z)

>> surf(X,Y,Z,'FaceColor','red','EdgeColor','none')

>> camlight left, lighting phong

>> view(15,65)

>> title('Prima suprafata')

>> subplot(2,2,2)

>> surf(X,Y,Z)

>> surf(X,Y,Z,'FaceColor','red','EdgeColor','none')

>> camlight left, lighting phong

>> view(0,90)

>> title('Cea de a 2-a suprafata')

>> subplot(2,2,3)

>> surf(X,Y,Z)

>> surf(X,Y,Z,'FaceColor','blue','EdgeColor','none')

>> camlight right, lighting phong

>> view(-30,30)

>> title('Cea de a 3-a suprafata')

Page 52: Proiect Matlab

Geometrie computationala

- 52 -

Calcul Simbolic in MATLAB

1. >> syms x real; >> t=x^2-3*x

t =

x^2 - 3*x

>> subs(t,2)

ans =

-2

>> subs(t,[1 -1.5 2])

ans =

-2.0000 6.7500 -2.0000

Exemplu personal

2. >> syms x real; >> f=x+3*x^2

f =

3*x^2 + x

>> subs(f,1)

ans =

4

>> subs(f,[2 3])

ans =

14 30

Page 53: Proiect Matlab

Geometrie computationala

- 53 -

3. >> syms x >> f=x^2*sin(x)-exp(x)

f =

x^2*sin(x) - exp(x)

>> diff(f)

ans =

x^2*cos(x) - exp(x) + 2*x*sin(x)

>> diff(f,3)

ans =

6*cos(x) - exp(x) - x^2*cos(x) - 6*x*sin(x)

Exemplu personal

4. >> syms x >> f=3*x^2+x^3

f =

x^3 + 3*x^2

>> diff(f)

ans =

3*x^2 + 6*x

>> diff(f,3)

ans =

6

5. >> syms x y >> z=x^2+x*y

z =

x^2 + y*x

Page 54: Proiect Matlab

Geometrie computationala

- 54 -

>> diff(z,x)

ans =

2*x + y

>> diff(z,y)

ans =

x

6. >> f=x^2*sin(x)-exp(x)

f =

x^2*sin(x) - exp(x)

>> int(f)

ans =

2*cos(x) - exp(x) - x^2*cos(x) + 2*x*sin(x)

7. >> int(f,0,2)

ans =

4*sin(2) - exp(2) - 2*cos(2) - 1

8. >> syms x; >> f=x^3-3*x+1;

>> ezplot(f,[-1 1]);

Page 55: Proiect Matlab

Geometrie computationala

- 55 -

9. >> syms x; >> ezplot('x^2 - 2*x + 1');

Page 56: Proiect Matlab

Geometrie computationala

- 56 -

10. >> syms x y; >> ex1='sqrt(4-x^2-y^2)';

>> figure(1); ezsurf(ex1,[-2,2,-2,2]);

11. >> syms x ; >> f=x^2-7*x+2;

>> solve(f)

ans =

7/2 - 41^(1/2)/2

41^(1/2)/2 + 7/2

12. >> clear, syms x y; >> eq = 'exp(2*x) = 3*y';

>> [x] = solve(eq,x)

x =

log(3*y)/2

13. 2x+3y-4z=5;

y+4z+x=10;

-2z+3x+4y=0;

Page 57: Proiect Matlab

Geometrie computationala

- 57 -

>> clear, syms x y z;

>> eq1 = '2*x-3*y+4*z = 5'

eq1 =

2*x-3*y+4*z = 5

>> eq2 = 'y+4*z+x = 10'

eq2 =

y+4*z+x = 10

>> eq3 = '-2*z+3*x+4*y = 0'

eq3 =

-2*z+3*x+4*y = 0

>> [x,y,z] = solve(eq1,eq2,eq3,x,y,z)

x =

-5/37

y =

45/37

z =

165/74

14.

>> syms x;

>> f=x^2;

>> limit(f,2)

ans =

4

Page 58: Proiect Matlab

Geometrie computationala

- 58 -

>> limit(f,inf)

ans =

Inf

>> limit(1/x,inf)

ans =

0

>> limit(log(abs(x)),0)

ans =

-Inf

Exemplu personal

15. >> syms x; >> f=sin(x)./x

f =

sin(x)/x

>> limit(f,Inf)

ans =

0

>> limit(f,0)

ans =

1

Page 59: Proiect Matlab

Geometrie computationala

- 59 -

Capitolul II

GEOMETRIA DIFERENȚIALĂ A CURBELOR

ÎN PLAN CU APLICAȚII ÎN MATLAB

Reprezentarea explicită a unei curbe plane

Exemplu personal 1. >> syms y;

>> y=sin(x);

>> ezplot(y)

>> title('Graficul functiei sin(x)');

>> legend('- sin(x)')

>> xlabel 'x'

>> ylabel ('f(x)=sin(x)')

Exemplu personal 2. >> x=0:.1:2*pi;

>> y=sin(x);

>> plot(y)

>> title('Graficul functiei sin(x)', 'FontSize', 14);

>> plot(y, '*r')

>> legend('functia sin(x)')

Page 60: Proiect Matlab

Geometrie computationala

- 60 -

3. >> x=[-pi:.3:pi]; >> y=sin(x);

>> z=cos(x);

>> plot(x,y,'-r');

>> hold on

>> plot(x,z,'--g');

>> hold on

>> plot(x,0,'*-b')

>> legend ('-sin(x)','-cos(x)','y=0');

Page 61: Proiect Matlab

Geometrie computationala

- 61 -

Reprezentarea implicită a unei curbe plane

1. >> x=linspace(-2,2);

>> plot(x,sqrt(4-x.^2))

>> hold on

>> plot(x,-sqrt(4-x.^2))

>> axis equal

2. >> t=-3:.01:3; >> x=t.^3-4*t;

>> y=t.^2-4;

>> plot(x,y)

Page 62: Proiect Matlab

Geometrie computationala

- 62 -

3. >> t=0:.01:2*pi; >> x=((sin(t)).^2+1).*cos(t);

>> y=((sin(t)).^2-1).*sin(t);

>> plot(x,y)

>> title('Curba lui Talbot')

Curbe date în coordonate polare

1. >> t=linspace(0,2*pi,200); >> r=1+sin(t);

>> polar(t,r);

>> title('Cardioida')

Page 63: Proiect Matlab

Geometrie computationala

- 63 -

2. >> th=0:2*pi/100:2*pi; >> ro=1+.2*cos(th);

>> polar(th,ro)

>> [x,y] = pol2cart(th,ro) ;

>> plot(x,y) ;

>> axis equal

>> [x,y] = pol2cart(th,ro)

Page 64: Proiect Matlab

Geometrie computationala

- 64 -

3. >> th=0:2*pi/100:2*pi; >> ro=3*th;

>> polar(th,ro)

Tangenta și normala într-un punct al unei curbe plane

Tangenta și normala într-un punct al unei curbe plane date explicit

1. >> syms x; >> y=sin(x);

>> ezplot(y,[0,2*pi])

>> dydx=diff(y)

dydx =

cos(x)

>> m=subs(dydx,x,2)

m =

-0.4161

>> y0=subs(y,x,2);

>> hold on;

>> ezplot(m*(x-2)+y0,[0,2*pi]);

>> title('tangenta dusa la o curba data explicit')

Page 65: Proiect Matlab

Geometrie computationala

- 65 -

Page 66: Proiect Matlab

Geometrie computationala

- 66 -

Capitolul III

GEOMETRIA DIFERENȚIALĂ A CURBELOR ÎN

SPAȚIU. REPREZENTǍRI ÎN MATLAB

1. >> t = -2*pi:.001:2*pi;

>> x=cos(t); y=sin(t);z=t;

>> plot3(x,y,z)

2. >> a=2; >> b=0.1;

>> w=2;

>> t=linspace(0,12*pi,500);

>> x=a*cos(w*t);

>> y=a*sin(w*t);

>> z=b*t;

>> plot3(x,y,z)

Page 67: Proiect Matlab

Geometrie computationala

- 67 -

3. >> alpha=0.2; >> t=linspace(-12*pi,12*pi,500);

>> x=cos(t)./sqrt(1+alpha^2*t.^2);

>> y=sin(t)./sqrt(1+alpha^2*t.^2);

>> z=alpha*t./sqrt(1+alpha^2*t.^2);

>> plot3(x,y,z)

Page 68: Proiect Matlab

Geometrie computationala

- 68 -

4. >> r=1

r =

1

>> phi=linspace(0,pi,30);

>> theta=linspace(0,2*pi,40);

>> [phi,theta]=meshgrid(phi,theta);

>> x=r*sin(phi).*cos(theta);

>> y=r*sin(phi).*sin(theta);

>> z=r*cos(phi);

>> mhndl=mesh(x,y,z)

mhndl =

171.0072

5. >> r=1; >> phi=linspace(0,pi,30);

>> theta=linspace(0,2*pi,40);

>> [phi,theta]=meshgrid(phi,theta);

>> x=2*r*sin(phi).*cos(theta);

>> y=2*r*sin(phi).*sin(theta);

>> z=2*r*cos(phi);

>> mhndl1=mesh(x,y,z)

Page 69: Proiect Matlab

Geometrie computationala

- 69 -

mhndl1 =

171.0117

>> set(mhndl1,...

'EdgeColor',[0.6,0.6,0.6])

>> axis equal

>> axis off

>> title('Curba lui Viviani')

Exemplu personal

6. >> t=linspace(0,2*pi,40); >> z=linspace(-2*r,2*r,20);

>> [t,z]=meshgrid(t,z);

>> x=r+r*cos(t);

>> y=r*sin(t);

>> z=z;

>> hold on

>> mhndl2=mesh(x,y,z)

mhndl2 =

171.0129

>> set(mhndl2,...

'EdgeColor',[0.8,0,0])

>> view(50,20)

Page 70: Proiect Matlab

Geometrie computationala

- 70 -

7. >> r=1; >> phi=linspace(0,pi,30);

>> theta=linspace(0,2*pi,40);

>> [phi,theta]=meshgrid(phi,theta);

>> x=2*r*sin(phi).*cos(theta);

>> y=2*r*sin(phi).*sin(theta);

>> z=2*r*cos(phi);

>> mhndl1=mesh(x,y,z)

mhndl1 =

171.0137

>> set(mhndl1,...

'EdgeColor',[0.6,0.6,0.6])

>> axis equal

>> axis off

>> t=linspace(0,2*pi,40);

>> z=linspace(-2*r,2*r,20);

>> [t,z]=meshgrid(t,z);

>> x=r+r*cos(t);

>> y=r*sin(t);

>> z=z;

>> hold on

>> mhndl2=mesh(x,y,z)

mhndl2 =

173.0132

Page 71: Proiect Matlab

Geometrie computationala

- 71 -

>> set(mhndl2,...

'EdgeColor',[0.8,0,0])

>> view(50,20)

8. >> theta=linspace(0,2*pi,40); >> r=linspace(-1,1,30);

>> [theta,r]=meshgrid(theta,r);

>> x=r.*cos(theta);

>> y=r.*sin(theta);

>> z=r;

>> mhndl=mesh(x,y,z)

mhndl =

171.0144

>> set(mhndl,...

'EdgeColor',[.6,.6,.6])

>> hold on

>> [x,y]=meshgrid(-1:0.2:1);

>> z=0.5*ones(size(x));

>> phndl=mesh(x,y,z);

>> set(phndl,...

'EdgeColor',[0.625,0,0])

>> view(116,38)

>> axis equal

>> axis off

Page 72: Proiect Matlab

Geometrie computationala

- 72 -

9. >> theta=linspace(0,2*pi,40); >> r=linspace(-1,1,30);

>> [theta,r]=meshgrid(theta,r);

>> x=r.*cos(theta);

>> y=r.*sin(theta);

>> z=r;

>> mhndl=mesh(x,y,z);

>> set(mhndl,...

'EdgeColor',[0.625,0,0])

>> set(mhndl,...

'EdgeColor',[.6,.6,.6])

>> hold on

>> [x,y]=meshgrid(-1:0.1:1);

>> z=y+0.25;

>>

>> phndl=mesh(x,y,z);

>> set(phndl,...

'EdgeColor',[0.625,0,0])

>> view(70,55)

>> axis equal

Page 73: Proiect Matlab

Geometrie computationala

- 73 -

10. >> r=linspace(0,1,30); >> theta=linspace(0,2*pi,30);

>> [r,theta]=meshgrid(r,theta);

>> x=r.*cos(theta);

>> y=r.*sin(theta);

>> z=r;

>> mesh(x,y,z)

>> axis tight

>> box on

>> xlabel('x-axis')

>> ylabel('y-axis')

>> zlabel('z-axis')

Page 74: Proiect Matlab

Geometrie computationala

- 74 -

11. >> u=linspace(0,6*pi,60); >> v=linspace(0,2*pi,60);

>> [u,v]=meshgrid(u,v);

>> x=2*(1-exp(u/(6*pi))).*cos(u).*cos(v/2).^2;

>> y=2*(-1+exp(u/(6*pi))).*sin(u).*cos(v/2).^2;

>> z=1-exp(u/(3*pi))-sin(v)+exp(u/(6*pi)).*sin(v);

>> mesh(x,y,z)

>> view(160,10)

>> box on

>> surf(x,y,z,...

'FaceColor','interp',...

'FaceLighting','phong')

>> camlight left

>> view(160,10)

>> axis equal

>> box on

12. >> a=3; >> b=4;

>> c=5;

>> u=linspace(0,2*pi,30);

>> [u,v]=meshgrid(u,v);

>> x=a*cos(u).*sin(v);

>> y=b*sin(u).*sin(v);

>> z=c*cos(v);

>> mesh(x,y,z)

>> box on

Page 75: Proiect Matlab

Geometrie computationala

- 75 -

Exemplu personal 13. >> a=9;

>> b=12;

>> c=6;

>> u=linspace(0,2*pi,60);

>> v=linspace(0,pi,60);

>> [u,v]=meshgrid(u,v);

>> x=a*cos(u).*sin(v);

>> y=b*sin(u).*sin(v);

>> z=c*cos(v);

>> mesh(x,y,z)

>> box on

>> surf(x,y,z,...

'FaceColor','interp',...

'EdgeColor','none',...

'FaceLighting','phong')

>> camlight left

>> view(160,10)

>> axis equal

>> box on

Page 76: Proiect Matlab

Geometrie computationala

- 76 -

14. >> x = pi/100:pi/100:10*pi; >> y = sin(x)./x;

>> plot(x,y)

>> grid

Page 77: Proiect Matlab

Geometrie computationala

- 77 -

15. >> x = pi/100:pi/100:10*pi; >> y = sin(x)./x;

>> plot(x,y)

>> grid

>> r=1;

>> phi=linspace(0,pi,30);

>> theta=linspace(0,2*pi,40);

>> [phi,theta]=meshgrid(phi,theta);

>> x=r*sin(phi).*cos(theta);

>> y=r*sin(phi).*sin(theta);

>> z=r*cos(phi);

>> mhndl=mesh(x,y,z)

mhndl =

171.0076

>> set(mhndl,...

'EdgeColor',[0.6,0.6,0.6],...

'EdgeAlpha',0.5,...

'FaceAlpha',0.5)

>> axis equal

>> axis off

>> alpha=0.2;

>> t=linspace(-12*pi,12*pi,500);

>> x=cos(t)./sqrt(1+alpha^2*t.^2);

>> y=sin(t)./sqrt(1+alpha^2*t.^2);

>> z=alpha*t./sqrt(1+alpha^2*t.^2);

>> lhndl=line(x,y,z)

lhndl =

173.0071

>> set(lhndl,...

'Color',[0.625,0,0],...

'LineWidth',2)

Page 78: Proiect Matlab

Geometrie computationala

- 78 -

16. >> t=linspace(0,4*pi,200);

>> x=r+r*cos(t);

>> y=r*sin(t);

>> z=2*r*sin(t/2);

>> vhndl=line(x,y,z)

vhndl =

0.0079

>> set(vhndl,...

'Color',[0,0,0],...

'LineWidth',2)

>> view(50,20)

Page 79: Proiect Matlab

Geometrie computationala

- 79 -

17. >> r=1; >> phi=linspace(0,pi,30);

>> theta=linspace(0,2*pi,40);

>> [phi,theta]=meshgrid(phi,theta);

>> x=2*r*sin(phi).*cos(theta);

>> y=2*r*sin(phi).*sin(theta);

>> z=2*r*cos(phi);

>> mhndl1=mesh(x,y,z)

mhndl1 =

171.0088

>> set(mhndl1,...

'EdgeColor',[0.6,0.6,0.6])

>> axis equal

>> axis off

>> t=linspace(0,2*pi,40);

>> z=linspace(-2*r,2*r,20);

>> [t,z]=meshgrid(t,z);

>> x=r+r*cos(t);

>> y=r*sin(t);

>> z=z;

>> hold on

>> mhndl2=mesh(x,y,z)

mhndl2 =

173.0083

>> set(mhndl2,...

'EdgeColor',[0.8,0,0])

>> view(50,20)

>> t=linspace(0,4*pi,200);

>> x=r+r*cos(t);

>> y=r*sin(t);

>> z=2*r*sin(t/2);

>> vhndl=line(x,y,z)

vhndl =

174.0083

>> set(vhndl,...

'Color',[0,0,0],...

'LineWidth',2)

>> view(50,20)

Page 80: Proiect Matlab

Geometrie computationala

- 80 -

18. >> t=linspace(0,1,200); >> x=3*sin(4*pi*t);

>> y=4*sin(6*pi*t);

>> z=5*sin(8*pi*t);

>> plot3(x,y,z)

>> box on

>> view(135,30)

Page 81: Proiect Matlab

Geometrie computationala

- 81 -

19. >> t=linspace(0,6*pi,200); >> x=cos(t).*(2-cos(2*t/3));

>> y=sin(t).*(2-cos(2*t/3));

>> z=-sin(2*t/3);

>> plot3(x,y,z)

>> box on

>> view(135,30)

20. >> t=linspace(0,2*pi,200); >> x=(6.25+3*cos(5*t)).*cos(2*t);

>> y=(6.25+3\cos(5*t)).*sin(2*t);

>> z=3.25*sin(5*t);

>> plot3(x,y,z)

>> box on

>> view(135,30)

Page 82: Proiect Matlab

Geometrie computationala

- 82 -

21. >> a=7;b=2;c=3; >> u=linspace(0,2*pi,20);

>> v=linspace(0,2*pi,40);

>> [u,v]=meshgrid(u,v);

>> x=(a+b*cos(u)).*cos(v);

>> y=(a+b*cos(u)).*sin(v);

>> z=c*sin(u);

>> mhndl=mesh(x,y,z);

>> set(mhndl,...

'EdgeColor',[.6,.6,.6],...

'FaceAlpha',0.5,...

'EdgeAlpha',0.5);

>> axis equal

>> t=linspace(0,2*pi,200);

>> x=(a+b*cos(5*t)).*cos(2*t);

>> y=(a+b*cos(5*t)).*sin(2*t);

>> z=c*sin(5*t);

>> lhndl=line(x,y,z);

>> set(lhndl,...

'Color',[.625,0,0],...

'LineWidth',2)

>> view(135,30)

Page 83: Proiect Matlab

Geometrie computationala

- 83 -

22. >> r=linspace(0,1,20); >> theta=linspace(0,2*pi,40);

>> [r,theta]=meshgrid(r,theta);

>> x=r.*cos(theta);

>> y=r.*sin(theta);

>> z=r;

>> mhndl=mesh(x,y,z);

>> set(mhndl,...

'EdgeColor',[.6,.6,.6],...

'FaceAlpha',0.5,...

'EdgeAlpha',0.5);

>> axis equal

>> t=linspace(0,1,200);

>> x=t.*cos(20*t);

>> y=t.*sin(20*t);

>> z=t;

>> lhndl=line(x,y,z);

>> set(lhndl,...

'Color',[.625,0,0],...

'LineWidth',2)

>> view(135,30)

Page 84: Proiect Matlab

Geometrie computationala

- 84 -

Exemple personale.

1. >> [X,Y] = meshgrid(-8:.5:8); >> R = sqrt(X.^2 + Y.^2) + eps;

>> Z = sin(R)./R;

>> mesh(X,Y,Z,'EdgeColor','black')

>> axis off

2. >> t = 0:pi/20:2*pi;

>> y = exp(sin(t));

>> plotyy(t,y,t,y,'plot','stem')

>> xlabel('X Axis')

>> ylabel('Plot Y Axis')

>> title('Two Y Axes')

Page 85: Proiect Matlab

Geometrie computationala

- 85 -

Bibliografie

1. VALER NIMINEȚ - Geometrie computațională cu aplicații în Matlab

2. CARMEN MURARU – Geometrie computațională

3. INTERNET – E-learn.ro


Recommended