You are on page 1of 6

Grafik X = Y

Source code
clear;
clc;
x = 0 : 5 : 50;
y = x;
plot(x , y)

Output

Source code
clear;
clc;
x = -50 : 5 : 50;
y = x.^2;
plot(x , y)

Output

Source code

clear;
clc;
x = 0 : 1 : 20;
y = x.^2;
plot(x , y)

Output

Program Menambahkan Judul Grid Line, Label dan Grafik

Source code
clear;
clc;
x = -50 : 10 : 50;
y = x.^2;
plot(x , y),xlabel('x'),ylabel('y'),grid on,title('grafik y = x^2')

Output

Grafik SIN dan COS

Source code
clear;
clc;
x = 0 : 0.02 : 20;
y = sin(x);
g = cos(x);
plot(x , y , x , g),xlabel('x'),ylabel('y'),grid on,title('grafik sin dan
cos')

Output

TUGAS PLOTING

Source code
clear;
clc;
x = -20 : 0.02 : 20;
f = 3 * x.^4 + 2 * x.^3 + 7 * x.^2 + 2 * x + 9;
g = 5 * x.^3 + 9 * x + 2;
plot(x , f , 'b' , x , g , 'm'),legend('f' , 'g'),xlabel('x'),ylabel('y'),
grid on,title('grafik f(x) dan g(x)')

Output

You might also like