You are on page 1of 1

0 to 2

1. x = 0:pi/100:2*pi;
y= sin(x);
plot(x,y)

2. Save as TWODPIsine

3. xlabel ('x')
ylabel ('y')
title ('Plot of the sine function')

4. plot(x,y,'r--')

5. Change --- to something else

6. Using x, y labelling, change to anything else

7. To add plots to an existing figure, use hold


x = 0:pi/100:2*pi;
y= sin(x);
plot(x,y)

hold on
y2 = cos(x);
plot (x, y2, ':')
legend ('sin' , 'cos')
;jgn tulis sine n cos, tulis lain

8. Tambah lagi 2 plot selain sine n cos. dalam satu panel.

9. Guna coding yg sama tetapi warna yg sama selain merah dan biru.

10. x = 0: 0.05:5;
y = sin (x.^2);
figure
plot (x,y)

try tukar 0.05 kepada 0.2

hold on (keluar dua2 graph)

11. 3-D plot


[X,Y] = meshgrid (-2:.2: 2);
Z= X.*exp(-X.^2 - Y.^2);
surf(X,Y,Z)

12. Tukar kecilkan scale and tambah range, add labeling : 0.07

13. t = 0:pi/10:2*pi;
[X,Y,Z] = cylinder(4*cos(t));
subplot(2,2,1); mesh(X); title ('X');
subplot(2,2,2); mesh(X); title ('Y');
subplot(2,2,3); mesh(Z); title ('Z');
subplot(2,2,4); mesh(X,Y,Z); title ('X,Y,Z');

14. Plot apa-apa, 3x3.

You might also like