Sie sind auf Seite 1von 45

Nr.

Functie Sursa program Grafic


Crt.
1. plot (x1, y1, …, xn, x = 0:pi/100:2*pi;
1
yn) y = cos(x);
0.8
plot(x, y)
0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 50 100 150 200 250

2. plot (x1, y1, …, xn, x = 1,3,9 7


yn) y = (x*x*x)-1;
plot(x, y) 6

0
0 50 100 150 200 250
3. plot (x1, y1, …, xn, x = [0, 1, 2,3,5,7,9,10,25,36,28]
yn) y = sqrt(x)
plot(x,y)

4. plot (x1, y1, …, xn, x=[ 10 ; 20;30;40;560;60] 40


yn) y=[1.000 7.4767; 2.3784 5.6569; 3.9482 3.9482; 5.6569
35
2.3784; 7.4767 1.0000]
plot(x,y) 30

25

20

15

10

0
1 2 3 4 5 6 7 8 9 10 11

5. plot (x1, y1, …, xn, x=0:0.1:100 1

yn) y=sin(x) 0.8

plot (x,y) 0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 10 20 30 40 50 60 70 80 90 100
6. plot(x1,y1,x2,y2… y1=sin-0.5 100
) y2=sin-3.14 90

plot(x,y,x,y2,x,y3) 80

70

60

50

40

30

20

10

0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

7. plot(x1,y1,x2,y2… x1=cos(x-.25);
) x2=tg (x-.3.14);
plot(x1,x2);

8. plot(x1,y1,x2,y2… t = 0: 0.01: pi; 1

) a = sin(2 * t); 0.8

b = sin(8 * t); 0.6

0.4
plot(t, a);
0.2
hold on 0

plot(t, b) -0.2

-0.4

-0.6

-0.8

-1
0 0.5 1 1.5 2 2.5 3 3.5
9. plot(x,y,s) x=5
y=2:9
plot(x,y, 'o')

10. plot(x,y,s) x=2


y=-3:7
plot(x,y,'rs')

11. plot(x,y,s) x=[1 2 2.5 4 5.5 6 7.5 9 10]


y=[1 2 3.2 4 5.7 6.5 7.9 9 9.7]
plot(x,y,'k*')

12. plot(x,y,s) >> x=[ 1 1 ; 2 2; 3 3; 4 4; 5 5];


>> y=[1.000 7.4767; 2.3784 5.6569; 3.9482 3.9482; 5.6569
2.3784; 7.4767 1.0000];
>> plot(x,y,'r:+')
13. plot(x,y,x,y2,x,y3) >>x=[ 1 1 ; 2 2; 3 3; 4 4; 5 5];
>>y=[1.000 7.4767; 2.3784 5.6569; 3.9482 3.9482; 5.6569
2.3784; >>7.4767 1.0000];
>> y2 = sin(x-.25);
>>y3 = sin(x-.5);
>>plot(x,y,x,y2,x,y3)
>>y2 = sin(x-.25);
>>y3 = sin(x-.5);

14. plot(x,y,x,y2,x,y3) >> x = 0:pi/200:8*pi;


>>y = cos(x);
>> y2 = cos(x-.25);
>> y3 = cos(x-.5);
>> plot(x,y,x,y2,x,y3)

15. hold on >> t = 0: 0.02: pi;


>> a = sin(9 * t);
>> b = cos(16 * t);
>> plot(t, a);
>> hold on
>> plot(t, b)
>>hold off
16. hold on >> t = 0: 0.01: 5*pi; a = sin(2 * t); plot(t, a);
>> hold on
>> b = cos(6 * t); plot(t, b);
>> hold on
>> c = sin(2 * t * pi);
>> plot(t, c);

17. hold on >> t=0:pi/10:2*pi;


>>x=sin(t.^2);
>>plot(t,x)
>> hold on
>> y=cos(t.^4);
>>plot(t,y)

18. Subplot (m, n, p) >>x=0:0.1:4*pi;


Loglog: >>subplot(1,3,1);plot(x,sin(x));xlabel('x');ylabel('sin(x)');
Sintaxa: >>subplot(1,3,2);plot(x,sin(x/2));xlabel('x');ylabel('sin(x/2)');
loglog(X,Y) >>subplot(1,3,3);plot(x,sin(2*x));xlabel('x');ylabel('sin(2*x)');
Semilogx :
Sintaxa:
semilogx(X,Y)
Semilogy:
Sintaxa:
semilogy(X,Y)
19 Subplot (m, n, >> t = 0: pi/20: 2*pi; x = sin(t.^2*pi); y = cos(t.^2*pi);
. p) >> z = x .* x;
Loglog: >> subplot(2, 2, 1)
Sintaxa: >> plot(t, x)
loglog(X,Y) >> grid
Semilogx : >> xlabel('t[s]')
Sintaxa: >> ylabel('sin(t)')
semilogx(X,Y) >> subplot(2, 2, 2)
Semilogy: >> plot(t, y)
Sintaxa: >> grid
semilogy(X,Y) >> xlabel('t[s]')
>> ylabel('cos(t)')
>> subplot(2, 2, 3)
>> plot(t, z)
>> grid
>> xlabel('t[s]')
>> ylabel('sin^2(t)')
>> subplot(2, 2, 4)
>> plot(x, y)
>> grid
>> xlabel('sin(t)')
>> ylabel('cos(t)')
20 Subplot (m, n, t = 0:pi/40:2.^4*pi;
. p) [x,y] = meshgrid(t);
Loglog: subplot(2,2,1)
Sintaxa: plot(sin(t),cos(t))
loglog(X,Y) axis equal
Semilogx : subplot(2,2,2)
Sintaxa: z = sin(x+t)+cos(y+t);
semilogx(X,Y) plot(t,z)
Semilogy: axis([0 2*pi -2 2])
Sintaxa: subplot(2,2,3)
semilogy(X,Y) z = sin(x.^2).*cos(y.^2);
plot(t,z)
axis([0 2*pi -1 1])
subplot(2,2,4)
z = (sin(x).^4)-(cos(y).^4);
plot(t,z)
axis([0 2*pi -1 1])

21 Subplot (m, n, x=0:0.05:3*pi;


. p) y=cos(x.^2).*cos(x.^2);
Loglog: hf=figure;
Sintaxa: subplot(2,2,1); plot(x,y); grid; xlabel('x [rad]');
loglog(X,Y) ylabel('cos(x.^2).*cos(x.^2)');
Semilogx : subplot(2,2,2); loglog(x,y); grid; xlabel('x [rad]');
Sintaxa: ylabel('cos(x.^2).*cos(x.^2)');
semilogx(X,Y) subplot(2,2,3); semilogx(x,y); grid; xlabel('x [rad]');
Semilogy: ylabel('cos(x.^2).*cos(x.^2)');
Sintaxa: subplot(2,2,4); semilogy(x,y); grid; xlabel('x [rad]');
semilogy(X,Y) ylabel('cos(x.^2).*cos(x.^2)');
22 Subplot (m, n, x=0:0.2:2*pi;
. p) subplot(2,2,1);plot(x,sin(sqrt(x)));xlabel('x');ylabel('sin(sqrt(x))');
Loglog: subplot(2,2,2);plot(x,cos(sqrt(x/2)));xlabel('x');ylabel('cos(sqrt(x/2))')
Sintaxa: ;
loglog(X,Y) subplot(2,2,3);plot(x,sin(2.^x));xlabel('x');ylabel('sin(2.^x)');
Semilogx :
Sintaxa:
semilogx(X,Y)
Semilogy:
Sintaxa:
semilogy(X,Y)
LABORATOR III

Nr. Crt. Functie Sursa program Grafic


1. xlabel('text dorit') t = -pi:pi/100:pi; 1
Graficul functiei cosinus

y = cos (t); 0.8

plot(t,y) 0.6

axis([-pi pi -1 1]) 0.4

xlabel('-\pi \leq {\itt} \leq \pi') 0.2

ylabel('sin(t)')

sin(t)
0

title('Graficul functiei cosinus') -0.2

text(1,-1/3,'{\itFunctia cosinus}') -0.4


Functia cosinus

-0.6

-0.8

-1
-3 -2 -1 0 1 2 3
- t

2. xlabel('sir', 'FontSize', 14) x = 0:.4:16; 16


plot(x,bessel(2,x),x,bessel(3,x),x,bessel(4,x));
14
legend('2','3','4',0);
12

10

0
0 5 10 15 20 25 30 35 40 45

3. xlabel('sir', 'FontSize', 14) x=0:0.1:2*pi; plot(x,sin(x),x,sin(x/2),x,sin(2*x)); 1


xlabel('x');ylabel('cos'); 0.8
cos(x)
cos(x/2)
legend('cos(x)','cos(x/2)','cos(2x)'); 0.6
cos(2x)

0.4

0.2

cos
0

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7
x
4. xlabel('sir', 'FontSize', 14) x = 0:pi/100:2*pi; 1

y = sin(x); 0.8

plot(x, y) 0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7

5. texlabel('expresie','literal') x=0:0.05:2*pi;
y=cos(x)./2; y1=cos(x); y2=sin(x); y3=cos(x).*sin(x);
hf=figure;
plot(x,y,x,y1,'rs:',x,y2,'gd-.',x,y3,'bv--'); grid;
xlabel('x [rad]'); ylabel('y'); title('y=f(x)')
legend('y=cos(x)/2','y=cos(x)','y=sin(x)','y=cos(x)*sin(x)');
text(0.2,-0.5,'Autor: E. Magda');
gtext('Coautor:Stud. Iancu Andrei Madalin.');

6. texlabel('expresie','literal') x=0:0.05:2*pi;
y=cos(x)./2; y1=cos(x); y2=sin(x); y3=cos(x).*sin(x);
hf=figure;
plot(x,y,x,y1,'rs:',x,y2,'gd-.',x,y3,'bv--'); grid;
xlabel('x [rad]'); ylabel('y'); title('y=f(x)')
legend('y=cos(x)/2','y=cos(x)','y=sin(x)','y=cos(x)*sin(x)');
text(0.2,-0.5,'Autor: E. Magda');
gtext('Coautor:Stud.Ciocmata Aurelia.');
7. axis(xmin, xmax, ymin, x = 0:pi/100:2*pi;
ymax) plot(exp(i*x),'-o');
axis equal;

8. axis(xmin, xmax, ymin, y = 2:pi/40:2*pi;


ymax) plot(exp(i*y),'-o');
axis equal;

LABORATORUL IV
1. polar(teta,r) x=0:pi/100:2*pi;
n=length(x);
y=cos(x);
hf=figure;
polar(x,y(1,:));
grid

2. polar(teta,r) x= 0:0.05:2*pi;
n=length(x);
y=sin(x);
hf=figure;
polar(x,y(1,:));
grid
3. polar(u,R); u=[0, 1, 2,3,5,7,9,10,25,36,2] : pi/10 : 2*pi;
R=pi * cos(u);
polar(u,R);
>>

4. polar(u,R); u=0 : pi/5 : 10*pi;


R=sin(u).*cos(u);
polar(u,R);
5. Compass(x) x=[3-12+i -14+2*i 4+8*i]
compass(x)

6. Compass(y) y=[12-15*i -24+27-i 84+8+i]


compass(y)
7. Compass(x, x=[1 2 4]; y=sin(x);
y) compass(x,y)

8. Compass(x, x=2*pi; y=-x;


y) compass(x,y)
9. Compass(z) zl = 25-i
grid z2 = pi * i
z3 = 3+2*i
z=[25-i, pi*i,3+2*i ]; compass(z); grid

10. Compass(z) zl = pi+i


grid z2 = 6+i
z3 = 7*i
z=[pi + i, 6+i,7*i ]; compass(z); grid
11. compass([ x = sin(90)+i
x, x/i, compass([x, x/i, x*i])
x*i])

12. compass([ y = 1500*i + pi


sin(y), compass([sin(y), y+i, y*i])
y+i,
y*i])

13. feather a=[5 3 7]; b=[9 -4 1]


(a,b) feather (a,b)

14.
15. feather c=pi*8; d=-sin(c)
(c,d) feather (c,d)

16. plot(x1, x1=[8 25 5 5];y1=[7 6 9 58]; x2=[7 8 2 4]; y2=[2 4 1


y1, x2, 8];
y2) plot(x1, y1, x2, y2)

17. plot(x1, x1=[5 4 2 1 3];y1=[ 6 8 2 0 1 ]; x2=[5 7 6 4 2];


y1, x2, y2=[ 0 9 4 8 6];
y2) plot(x1, y1, x2, y2)
18. fill(x1, x1=[0 2 3 -1 0];y1=[-1 0 3 2 -1]; x2=[2 3 5 4 2];
y1, g, y2=[0 3 2 0 0];g=1;b=1;
x2, y2, fill(x1, y1, g, x2, y2, b)
b) x1=[0 2 3 -1 0];y1=[-1 0 3 2 -1]; fill(x1, y1, g, g,
fill(x1, g, g)
y1, g, g,
g, g)

19. fill(x1, x1=[7 9 4 2 1];y1=[-5 8 1 2 3]; x2=[0 3 1 7 8];


y1, g, y2=[1 4 2 7 5];g=1;b=1;
x2, y2, fill(x1, y1, g, x2, y2, b)
b) x1=[9 1 4 5 0];y1=[ 2 3 4 9 1]; fill(x1, y1, g, g,
fill(x1, g, g)
y1, g, g,
g, g)

20. subplot(3 subplot(321)


21) fill([9 1 8],[3 4 9 ],'r')
subplot(3 subplot(322)
22) fill([6 3 2],[0 4 9],'r', [1 8 4],[2 8 4], 'g')

21. subplot(4 subplot(423)


23) fill([1 0 2],[2 3 5 ],'r')
subplot(4 subplot(431)
31) fill([2 1 7],[2 7 3],'r', [9 1 4],[3 4 8], 'g')
22. Level
area a=1:10;b=-a.^2;area(a,b,50)

23. Level c=5:100;d=pi*c.^2;area(c,d,100)


area
24. bar(x) x=[5 2 6 6 pi 2*4 3]
bar(x)

25. bar(y) y=[10/2 4 5*4 pi*pi 7/5 3]


bar(y)
26. bar(Y) Y = [10 2 1
6 9 0
2 8 1
7 10 7
2 72 4];
bar(Y)

27. bar(Y) Y = [0 5 1
pi*pi -9 0
2 8 8
5 10 10/2
pi/3 8 pi*8];
bar(Y)
28. pareto(x) x=0:0.12:6
sum(x); x/sum(x)
pareto(x)

29. pareto(x) x=1:1.36:6


sum(x); x/sum(x)
pareto(x)

30. PIE pie([pi*pi 20 31 100/2],


{"Pitesti","Bucuresti","Brasov","Alexandria"})
31. PIE pie([3*8 40/2 2*2+5 pi*10/5],
{"Constanta","Bihor","Arges","Dolj"})

32. plotmatrix( a = randn(50,3); y = a*[8 5 2;-2 4 3;5 20-5 2*3;];


plotmatrix(y)
a)

33. plotmatrix( x = randn(50,3); y = x*[pi 10/5 1;-60 0 8;4 -2 7;];


plotmatrix(y)
y)
LABORATORUL V

Nr. Crt. Functia Sursa program Grafic


1. plot5(x1,y1,z1,'linie t=-15:0.236:15;
x=(2*t.^2).*sin(2+t);
-tip’,x2,y2,z2,'linie- y=(1+t.^2).*cos(20*t);
tip2',...) z=t;
plot3(x,y,z)
grid on
xlabel('x(t)','FontSize',20);
ylabel('y(t)','FontSize',20);
zlabel('z(t)','FontSize',20);
title('{\itPlot} 3','FontSize',20)

2. plot5(x1,y1,z1,'linie t=-30:1.36:2;
x=(2*t.^2).*sin(2+t);
-tip’,x2,y2,z2,'linie-
y=(1+t.^2).*cos(20*t);
tip2',...) z=t;
plot3(x,y,z)
grid on
xlabel('x(t)','FontSize',15);
ylabel('y(t)','FontSize',20);
zlabel('z(t)','FontSize',15);
title('{\itPlot} 3','FontSize',20)

3. plot5(x1,y1,z1,'linie t=-15:0.002:15;
x=(1+t.^2).*sin(20*t);
-tip’,x2,y2,z2,'linie-
y=(1+t.^2).*cos(20*t);
tip2',...) z=t;
plot3(x,y,z)
grid on
xlabel('x(t)','FontSize',20);
ylabel('y(t)','FontSize',20);
zlabel('z(t)','FontSize',20);
title('{\itPlot} 3','FontSize',20)
4. plot3 t = 2:3/50:15*pi;
subplot(221)
plot(t,sin(t),'-r')
grid on;
subplot(223)
plot(t,sin(t),'-g')
subplot(122)
plot3(sin(t),cos(t),t,':pb')

5. plot3 t = 4*pi/20:10*pi;
subplot(221)
plot(t,sin(t),'-r')
grid on;
subplot(223)
plot(t,cos(t),'-g')
subplot(122)
plot3(cos(t),sin(t),t,':pb')

6. fill3(X,Y,Z,C) X = [1 2 pi 2; 0 1 4 2; 1 0 2 1];
Y = [1 2 1 2; 1 0 2 0; 0 1 0 1];
Z = [2 1 3 1; 7 0 2 1; 1 0 0 0];
C = [0.5000 1.0000 1.0000 0.5000;
1.0000 0.5000 0.5000 0.1667;
0.3330 0.3330 0.5000 0.5000];

fill3(X,Y,Z,C)
7. fill3(X,Y,Z,C) A = [0 1 1 2; 1 1 2 2; 0 0 1 1];
B = [1 1 1 1; 1 0 1 0; 0 0 0 0];
D = [1 1 1 1; 1 0 1 0; 0 0 0 0];
C = [0.5000 1.0000 1.0000 0.5000;
1.0000 0.5000 0.5000 0.1667;
0.3330 0.3330 0.5000 0.5000];

fill3(A,B,D,C)

8. Comet(x) t = 0:.25:5
comet3(sin(t),cos(t),t)

9. Comet(x) t = 1:.5:22
comet3(pi*(t),cos(t),t)
10. Mesh [X,Y]=meshgrid (-1:.8:2, -2:.2:2);
Z=Y.*exp(-X*pi.^2-Y.^2);
subplot(221);mesh(X,Y,Z)
subplot(222);meshc(X,Y,Z)
subplot(223);meshz(X,Y,Z)

11. Mesh [X,Y]=meshgrid (-1:.2:4, -2:.1:2);


Z=2*X.*exp(-X.^2-Y.^2);
subplot(221);mesh(X,Y,Z)
subplot(222);meshc(X,Y,Z)
subplot(223);meshz(X,Y,Z)

12. M(2,2,2) plot3(4, 2, 8, 'bo');


line([2 2],[2 2],[0 2]);
grid on
13. M(2,2,2) plot3(10, 9, 7, 'bo');
line([4 4],[4 4],[0 2]);
grid on

14. M(2,2,2) [x,y] =meshgrid(2:5); z = x+2*y-4;


plot3(x, y, z, 'ro'); grid
15. mesh(x,y,z,c) [X,Y] = meshgrid(-10:.7:17);
mesh(x,y,z) R = sqrt(X.^2 + Y.^2) + eps;
Z = cos(R)./R; mesh(Z);
mesh(z) grid
h = mesh(...)

16. mesh(x,y,z,c) [X,Y] = meshgrid(-5:.4:8);


mesh(x,y,z) R = sin(X.^2 + Y.^2) + eps;
Z = cos(R)./R; mesh(Z);
mesh(z) grid
h = mesh(...)
17. mesh(x,y,z,c) x = 0:0.1:pi; y=0:0.1:pi; [X,Y]=meshgrid(x,y);
mesh(x,y,z) Z=sin(Y.^2+X)-cos(Y-X.^2);
subplot(221); mesh(Z); subplot(222); meshc(Z);
mesh(z) subplot(223); mesh(x,y,Z);
h = mesh(...) axis([0 pi 0 pi -5 5]); subplot(2,2,4);
mesh(Z);
hidden off

18. mesh(x,y,z,c)
mesh(x,y,z)
x=[-2:.2:2];
mesh(z) y=[-1:.1:2];
h = mesh(...) [X,Y]=meshgrid(x,y);
z=X.^3+(Y/2).^3;
subplot(1,2,2); mesh(
19. mesh(x,y,z,c) x=[-7:.7:7];
mesh(x,y,z) y=[-2:.2:2];
[X,Y]=meshgrid(x,y);
mesh(z) z=X.^3+(Y/2).^3;
h = mesh(...) subplot(1,2,2); mesh(z)

20. mesh(x,y,z,c) [X, Y] = meshgrid([-4:1.2:2]);


mesh(x,y,z) Z = X.*exp(-X.^2-Y.^2);
plot3(X,Y,Z);
mesh(z) grid
h = mesh(...)
21. mesh(x,y,z,c) [X, Y] = meshgrid([-2:0.1:2]);
mesh(x,y,z) Z = X.*exp(-X.^2-Y.^2);
plot3(X,Y,Z);
mesh(z) grid
h = mesh(...)

22. surf(X.Y,Z,C) [X,Y]=meshgrid(-7:.26:4); Z=peaks(X,Y);


surfc(X,Y,Z)

23. surf(X.Y,Z,C) [X,Y]=meshgrid(-8:.22:2); Z=peaks(X,Y);


surfc(X,Y,Z)
24. meshgrid [X,Y]=meshgrid(-8:.22:2); Z=peaks(X,Y);
surfc(X,Y,Z)

25. meshgrid [x,y] =meshgrid(2:6); z =2*x+4*y-8;


mesh(x,y,z);
grid
26. surf(X.Y,Z,C) x = -9:.5:8;
y = -9:.5:8;
[x,y] = meshgrid (x,y);
R = sqrt (x.^2 + y.^2) +eps;
z = sin (R)./R;
surfl (z);
shading interp; colormap (flag)

27. surf(X.Y,Z,C) x = -9:.5:8;


y = -9:.5:8;
[x,y] = meshgrid (x,y);
R = sqrt (x.^2 + y.^2) +eps;
z = cos (R)./R;
surfl (z);
shading interp; colormap (flag)

Laboratorul 6

Nr.crt. Functie Sursa program Grafic


1. caxis(caxis) [X,Y,Z]=sphere(44);
C=Z;
subplot (221);
surf(X,Y,Z,C);

2. caxis(caxis) [X,Y,Z]=sphere(37);
C=Y;
subplot (221);
surf(X,Y,Z,C);

3. colormap(map) load cape


figure
colormap(map)
subplot(2,2,1)
image(X,'CDataMapping','scaled')
title('caxis = [1 192]')
subplot(2,2,2)
image(X,'CDataMapping','scaled')
caxis([4,192]) % change caxis
title('caxis = [5 178]')
subplot(2,2,3)
image(X,'CDataMapping','scaled')
caxis([7,192]) % change caxis
title('caxis = [1 182]')
subplot(2,2,4)
image(X,'CDataMapping','scaled')
caxis([10,192]) % change caxis
title('caxis = [12 199]')
4. colormap(map) load cape
figure
colormap(map)
subplot(2,2,1)
image(X,'CDataMapping','scaled')
title('caxis = [3 195]')
subplot(2,2,2)
image(X,'CDataMapping','scaled')
caxis([4,192])
title('caxis = [7 157]')
subplot(2,2,3)
image(X,'CDataMapping','scaled')
caxis([7,192])
title('caxis = [1 178]')
subplot(2,2,4)
image(X,'CDataMapping','scaled')
caxis([10,192])
title('caxis = [8 114]')
5. Shading(default) figure
subplot(2,2,1)
sphere(20)
title('Faceted Shading (Default)')

6. Shading(Interp) subplot(2,2,3)
sphere(22)
shading interp
title('Interpolated Shading')
7. Shading(default,inter,interp figure
) subplot(2,2,1)
sphere(44)
title('Faceted Shading (Default)')
subplot(2,2,2)
sphere(52)
shading flat
title('Flat Shading')
subplot(2,2,3)
sphere(10)
shading interp
title('Interpolated Shading')

8. pcolor pcolor(hadamard(20))
colormap(green(2))
9. pcolor pcolor(hadamard(20))
colormap(prism(10))

10. pcolor(X,Y,C) n=8; r=(1:n)'/n; t=pi+(-n:n)/n;


X=r*cos(t); Y=r*sin(t); C=r*cos (2*t) ;
pcolor(X,Y,C); axis('square')
11. pcolor(X,Y,C) n=5; r=(0:n)'/n; t=pi*(-n:n)/n;
X=r*cos(t); Y=r*sin(t); C=r*cos (2*t) ;
pcolor(X,Y,C); axis('square')

12. colormap figure


ax1 = subplot(2,1,1);
contourf(peaks)
colormap(ax1,hot(8));
ax2 = subplot(2,1,2);
contourf(peaks)
colormap(ax2,green);
13. colormap figure
ax1 = subplot(2,1,1);
contourf(peaks)
colormap(ax1,hot(15));
ax2 = subplot(2,1,2);
contourf(peaks)
colormap(ax2,prism);

14. surfnorm [x,y,z] = cylinder(1:20);


figure
surfnorm(x,y,z)
15. surfnorm [x,y,z] = cylinder(1:50);
figure
surfnorm(x,y,z)

16. drawnow % initialize surface object


x = -pi:0.1*pi;
xsize = size(x,2);
f = zeros(xsize);
for y = 1:xsize
f(:,y) = cos(y/xsize*pi) + sin(x);
end
% draw surface first time
hSurface = surface(f, 'LineStyle', 'none');
view(3); % set the default 3D view
% function drawing loop
for j=0:0.01:10
% update surface function
for y = 1:xsize
f(:,y) = cos(y/xsize*pi+j) + sin(x+j);
end
% update surface ZData
set(hSurface, 'ZData', f);
drawnow;
end
t = 0:pi/20:2*pi;
y = exp(sin(t));
h = plot(t,y,'YDataSource','y');
for k = 1:.1:10
y = exp(sin(t.*k));
refreshdata(h,'caller')
% Evaluate y in the function workspace
drawnow;
pause(.1)
end

17. drawnow % initialize surface object


x = -pi:0.1/pi;
xsize = size(x,2);
f = zeros(xsize);
for y = 1:xsize
f(:,y) = cos(y/xsize*pi) + sin(x);
end
% draw surface first time
hSurface = surface(f, 'LineStyle', 'none');
view(3); % set the default 3D view
% function drawing loop
for j=0:0.01:10
% update surface function
for y = 1:xsize
f(:,y) = cos(y/xsize*pi+j) + sin(x+j);
end
% update surface ZData
set(hSurface, 'ZData', f);
drawnow;
end
t = 1:pi/20:4*pi;
y = exp(sin(t));
h = plot(t,y,'YDataSource','y');
for k = 1:.1:10
y = exp(sin(t.*k));
refreshdata(h,'caller')
% Evaluate y in the function workspace
drawnow;
pause(.1)
end