tipe plot

2
a) Tipe Plot >> x=linspace(0,2*pi,30); >> y=sin(x); >> plot(x,y) 0 1 2 3 4 5 6 7 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 b) Tipe Plot x=0:0.5:20; >> y=2*x.^2+5*x+2; >> z=sqrt(4*x+2); >> >> subplot(2,1,1) >> plot(x,y,'r') >> grid on; >> xlabel('Nilai x'),ylabel('Nilai y') >> legend('x thd y') >> subplot(2,1,2) >> plot(x,z,'b') >> grid on; >> xlabel('Nilai x'),ylabel('Nilai z') >> legend('x thd z') 0 2 4 6 8 10 12 14 16 0 200 400 600 800 1000 Nilaix Nilaiy 0 2 4 6 8 10 12 14 16 0 2 4 6 8 10 Nilaix Nilaiz c) Tipe stem >> x=0:0.5:20; >> y=2*x.^2+5*x+2; >> z=sqrt(4*x+2); >> >> subplot(2,1,1) >> stem(x,y,'r') >> grid on; >> xlabel('Nilai x'),ylabel('Nilai y') >> legend('x thd y') >> subplot(2,1,2) >> stem(x,z,'b') >> grid on; >> xlabel('Nilai x'),ylabel('Nilai z') >> legend('x thd z') 0 2 4 6 8 10 12 14 16 18 20 0 200 400 600 800 1000 Nilaix Nilaiy 0 2 4 6 8 10 12 14 16 18 20 0 2 4 6 8 10 Nilaix Nilaiz x thd y x thd z d) Tipe Stem x=0:0.5:20; >> y=2*x.^2+5*x+2; >> z=sqrt(4*x+2); >> >> subplot(2,1,1) >> bar(x,y,'g') >> grid on; >> xlabel('Nilai x'),ylabel('Nilai z') >> legend('x thd y') >> >> subplot(2,1,2) >> bar(x,z,'m') >> grid on; >> xlabel('Nilai x'),ylabel('Nilai z') >> legend('x thd z') -5 0 5 10 15 20 25 0 200 400 600 800 1000 Nilaix Nilaiz -5 0 5 10 15 20 25 0 2 4 6 8 10 Nilaix Nilaiz x thd y x thd z e) Tipe Stairs x=0:0.5:20; >> y=2*x.^2+5*x+2; >> z=sqrt(4*x+2); >>

Upload: nisa-nuraini

Post on 02-Oct-2015

216 views

Category:

Documents


0 download

DESCRIPTION

-

TRANSCRIPT

a) Tipe Plot>> x=linspace(0,2*pi,30);>> y=sin(x);>> plot(x,y)

b) Tipe Plotx=0:0.5:20;>> y=2*x.^2+5*x+2;>> z=sqrt(4*x+2);>> >> subplot(2,1,1)>> plot(x,y,'r')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai y')>> legend('x thd y')>> subplot(2,1,2)>> plot(x,z,'b')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai z')>> legend('x thd z')

c) Tipe stem>> x=0:0.5:20;>> y=2*x.^2+5*x+2;>> z=sqrt(4*x+2);>> >> subplot(2,1,1)>> stem(x,y,'r')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai y')>> legend('x thd y')

>> subplot(2,1,2)>> stem(x,z,'b')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai z')>> legend('x thd z')

d) Tipe Stemx=0:0.5:20;>> y=2*x.^2+5*x+2;>> z=sqrt(4*x+2);>> >> subplot(2,1,1)>> bar(x,y,'g')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai z')>> legend('x thd y')>> >> subplot(2,1,2)>> bar(x,z,'m')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai z')>> legend('x thd z')

e) Tipe Stairsx=0:0.5:20;>> y=2*x.^2+5*x+2;>> z=sqrt(4*x+2);>> >> subplot(2,1,1)>> stairs(x,y,'r')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai y')>> legend('x thd y')>> subplot(2,1,2)>> stairs(x,z,'b')>> grid on;>> xlabel('Nilai x'),ylabel('Nilai z')>> legend('x thd z')

f) Tugas 1>> x=linspace(0,2*pi,20);>> y1=sin(x);>> y2=cos(x);>> plot(x,y1,'r')>> hold on>> plot(x,y2,'y')

g) Tugas 2>> z=[ 20 6 14 95; 18 3 28 11; 1 5 27 6; 21 10 22 12]

z =

20 6 14 95 18 3 28 11 1 5 27 6 21 10 22 12b=z'

b =

20 18 1 21 6 3 5 10 14 28 27 22 95 11 6 12mean(z)

ans =

18.6875>> max(z)

ans =

95

>> min(z)

ans =

1

h) >> bar(T)>> T=[10 20 30 40, 5 15 25 35, 7 14 7 20];bar(T)grid on;

i)