no. 1

27
I. Kerjakan semua contoh soal yang ada di appendix 1 dengan matlab . Running programnya dan analis ahasilnya 1. 3-4i sing Toolbox Path Cache. Type "help toolbox_path_cache" for more info. To get started, select "MATLAB Help" from the Help menu. >> ans = 3.0000 - 4.0000i >> Hasil Analisa : “Apabila kita menuliskan bilangan imajiner, maka pada command window hasil yang tertampil sebagaimana seperti yang diatas.” 2. Fungsi Roots(p1) p1=[1 -10 35 -50 24]; roots_p1=roots(p1) >> roots_p1 = 4.0000 3.0000 2.0000 1.0000 >> Hasil Analisa :

Upload: destfa

Post on 22-Oct-2014

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: No. 1

I. Kerjakan semua contoh soal yang ada di appendix 1 dengan matlab . Running programnya dan analis ahasilnya

1. 3-4i

sing Toolbox Path Cache. Type "help toolbox_path_cache" for more info.

To get started, select "MATLAB Help" from the Help menu.

>>

ans =

3.0000 - 4.0000i

>>

Hasil Analisa :

“Apabila kita menuliskan bilangan imajiner, maka pada command window hasil yang tertampil sebagaimana seperti yang diatas.”

2. Fungsi Roots(p1)p1=[1 -10 35 -50 24]; roots_p1=roots(p1)

>> roots_p1 = 4.0000 3.0000 2.0000 1.0000>>

Hasil Analisa :

“Fungsi perintah yang ditulis pada comand window sebagaimana diatas digunakan untuk menemukan akar dari perhitungan persamaan polynomial.

Page 2: No. 1

3. p2=[1 -7 0 16 25 52]roots_p2=roots(p2)>> p2 = 1 -7 0 16 25 52roots_p2 = 6.5014 2.7428 -1.5711 -0.3366 + 1.3202i -0.3366 - 1.3202i>>

Hasil Analisa :

“Fungsi perintah diatas, digunakan untuk menemukan hasil perhitungan akar dari persamaan polynomial. Pada aplikasinya akan menghasilkan 2 bilangan nyata dan 3 bilangan complex”

4. Bentuk Polynomial dari akar yang telah diketahuir3=[1 2 3 4]poly_r3=poly(r3)>> r3 = 1 2 3 4

poly_r3 = 1 -10 35 -50 24>>

Hasil Analisa :

“Dengan fungsi Poly(r3), dari akar yang diketahui dapat diperoleh hasil persamaan x4 - 10x3 + 35x2 - 50x + 24”

Page 3: No. 1

5. r4=[ -1 -2 -3 -4+5j -4-5j ]poly_r4=poly(r4)>> r4 = -1.0000 -2.0000 -3.0000 -4.0000 + 5.0000i -4.0000 - 5.0000i

poly_r4 = 1 14 100 340 499 246>>

Hasil Analisa :

“Dengan fungsi perintah dari Poly(r4), dari akar yang 2 bilangan nyata dan 3 bilangan complex yang telah ditentukan ,dapat diperoleh hasil persamaan X5 + 14x4 + 100x3 + 340x2 + 499x + 246”

6. Menentukan nilai dari persamaan PolynomialX6 -3X5 + 5x3 - 4x2 + 3x + 2X=-3p5=[1 -3 0 5 -4 3 2]; val_minus3=polyval(p5, -3)>> val_minus3 = 1280>>

Hasil Analisa :

“Nilai – nilai dari persamaan diatas didapat dari memasukkan data nilai x=-3 ke persamaan sehingga hasil pada command window tertera seperti hasil diatas.”

Page 4: No. 1

7. Conv(a,b) adalah perkalian 2 persamaan Polynomial

p1=[1 -3 0 5 7 9]; p2=[2 0 -8 0 4 10 12]; p1p2=conv(p1,p2)>> p1p2 = 2 -6 -8 34 18 -24 -74 -88 78 166 174 108>>

Hasil Analisa :

“Dari hasil perkalian didapat hasilP1.p2= 2X11 -6X10 - 8x9 + 34x8 + 18x7 - 24X6 -74x5 - 88x4 + 78x3 + 166x2 + 174x -108 “

8. [q,r]=deconv(p3,p4) adalah pembagian 2 persamaan Polynomial

p3=[1 0 -3 0 5 0 7 9]; p4=[2 -8 0 0 4 10 12]; [q,r]=deconv(p3,p4)>> q = 0.5000

r = 0 4 -3 0 3 2 3>>

Hasil Analisa :

“ Dari hasil perhitungan fungsi diatas didapatkan hasil

Page 5: No. 1

9. Polyder digunakan untuk menghitung persamaan d p5 dx

p5=[2 0 -8 0 4 10 12];poly=polyder(p5)>> poly = 12 0 -32 0 8 10>>

Hasil Analisa :

“Hasilnya adalah

10. Rasio Polynomial adalah perbandingan penyebut dan pembilang

num=[1 -3 0 5 7 9]; den=[1 0 -4 0 2 5 6];roots_num=roots(num), roots_den=roots(den) >> roots_num = 2.4186 + 1.0712i 2.4186 - 1.0712i -1.1633 -0.3370 + 0.9961i -0.3370 - 0.9961i

roots_den = 1.6760 + 0.4922i 1.6760 - 0.4922i -1.9304 -0.2108 + 0.9870i -0.2108 - 0.9870i

Page 6: No. 1

-1.0000 >>

Hasil Analisa :

Yang dimaksud dengan Rasio Polynomial adalah perbandingan antara penyebut dan pembilangUntuk Numerator formatnya adalah:

Sedangkan untuk Denominaror

Page 7: No. 1

11. Plot(x,y)w=[300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900....2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000];

z=[39.339 52.789 71.104 97.665 140.437 222.182 436.056.... 1014.938 469.830 266.032 187.052 145.751 120.353 103.111.... 90.603 81.088 73.588 67.513 62.481 58.240 54.611 51.468.... 48.717 46.286 44.122 42.182 40.432 38.845]; plot(w,z)

Page 8: No. 1

12. Memberi judul , grid dan label.w=[300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900....2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000];

z=[39.339 52.789 71.104 97.665 140.437 222.182 436.056.... 1014.938 469.830 266.032 187.052 145.751 120.353 103.111.... 90.603 81.088 73.588 67.513 62.481 58.240 54.611 51.468.... 48.717 46.286 44.122 42.182 40.432 38.845];

plot(w,z)grid ontitle('LATIHAN APENDIK 1')xlabel('Z')ylabel('W')

Page 9: No. 1

13. Gelombang sinusoidalx=linspace(0, 2*pi, 60); y=sin(x); u=sin(x+2*pi/3); v=sin(x+4*pi/3); plot(x,y,x,u,x,v); grid on, box on,text(1, 0.8, 'sin(x)'); text(2.85, 0.65, 'sin(x+2*pi/3)'); text(4.95, 0.65, 'sin(x+4*pi/3)')

plot(x,y,'m*:')=Warna magenta

Page 10: No. 1

14. Plot Fungsix=2 ; 6; 10;y=xz=-2*x^3+x+3*y^2-1plot3(x,y,z); grid

Page 11: No. 1

15. [R,H]=meshgrid(0: 4, 0: 6); V=(pi .* R .^ 2 .* H) ./ 3; mesh(R, H, V)xlabel('x-axis, radius r (meters)'); ylabel('y-axis, altitude h (meters)');zlabel('z-axis, volume (cubic meters)'); title('Volume of Right Circular Cone'); box on

Page 12: No. 1

16. Subplot(m,n,p)a. Matrix Multiplication (multiplication of row by column vectors)A=[1 2 3 4 5]; B=[ −2 6 −3 8 7]'; A*B>> ans =

68

>>b. Element-by-Element Multiplication (multiplication of a row vector by another row

vector)C=[1 2 3 4 5]; D=[-2 6 -3 8 7]; C.*D>> ans =

-2 12 -9 32 35

>>

Page 13: No. 1

17. Perkalian exponent

t=0:0.01: 5 % Define t-axis in 0.01 incrementsy=3 .* exp(-4 .* t) .* cos(5 .* t)-2 .* exp(-3 .* t) .* sin(2 .* t) + t .^2 ./ (t+1);plot(t,y); grid; xlabel('t'); ylabel('y=f(t)'); title('Plot for Example A.13')

Page 14: No. 1

18. Perkalian sudutx=linspace(0,2*pi,100); % Interval with 100 data pointsy=(sin(x).^ 2); z=(cos(x).^ 2); w=y.* z;v=y./ (z+eps); % add eps to avoid division by zerosubplot(221); % upper left of four subplotsplot(x,y); axis([0 2*pi 0 1]);title('y=(sinx)^2');subplot(222); % upper right of four subplotsplot(x,z); axis([0 2*pi 0 1]); title('z=(cosx)^2');subplot(223); % lower left of four subplotsplot(x,w); axis([0 2*pi 0 0.3]);title('w=(sinx)^2*(cosx)^2');subplot(224); % lower right of four subplotsplot(x,v); axis([0 2*pi 0 400]);title('v=(sinx)^2/(cosx)^2');

Page 15: No. 1

19. Persamaan bilangan real dan imajiner

w=0: 1: 2000; % Define interval with one radian intervalz=(10+(10 .^ 4 -j .* 10 .^ 6 ./ (w+eps)) ./ (10 + j .* (0.1 .* w -10.^5./ (w+eps))));real_part=real(z); plot(w,real_part); grid;xlabel('radian frequency w'); ylabel('Real part of Z');

Plot for the real part of the impedance

w=0: 1: 2000; % Define interval with one radian intervalz=(10+(10 .^ 4 -j .* 10 .^ 6 ./ (w+eps)) ./ (10 + j .* (0.1 .* w -10.^5./ (w+eps))));real_part=real(z); plot(w,real_part); grid;xlabel('radian frequency w'); ylabel('Real part of Z');

Page 16: No. 1

imag_part=imag(z); plot(w,imag_part); grid;xlabel('radian frequency w'); ylabel('Imaginary part of Z');

Plot for the imaginary part of the impedance

w=0: 1: 2000; % Define interval with one radian intervalz=(10+(10 .^ 4 -j .* 10 .^ 6 ./ (w+eps)) ./ (10 + j .* (0.1 .* w -10.^5./ (w+eps))));real_part=real(z); plot(w,real_part); grid;xlabel('radian frequency w'); ylabel('Real part of Z');

imag_part=imag(z); plot(w,imag_part); grid;xlabel('radian frequency w'); ylabel('Imaginary part of Z');

mag=abs(z); %rndz=round(abs(z)); %theta=angle(z); %polar(theta,rndz); %

Page 17: No. 1

grid;ylabel('Polar Plot of Z');

Polar plot of the impedance

Page 18: No. 1

20. function y = myfunction(x)Menentukan maksimum dan minimum dari fungsi tersebut

x=-1.5: 0.01: 1.5; y=1./ ((x-0.1).^ 2 + 0.01) +1./ ((x-1.2).^ 2 + 0.04) -10; plot(x,y); grid

>> help format

FORMAT Set output format. All computations in MATLAB are done in double precision. FORMAT may be used to switch between different output display formats as follows: FORMAT Default. Same as SHORT.

Page 19: No. 1

FORMAT SHORT Scaled fixed point format with 5 digits. FORMAT LONG Scaled fixed point format with 15 digits. FORMAT SHORT E Floating point format with 5 digits. FORMAT LONG E Floating point format with 15 digits. FORMAT SHORT G Best of fixed or floating point format with 5 digits. FORMAT LONG G Best of fixed or floating point format with 15 digits. FORMAT HEX Hexadecimal format. FORMAT + The symbols +, - and blank are printed for positive, negative and zero elements Imaginary parts are ignored. FORMAT BANK Fixed format for dollars and cents. FORMAT RAT Approximation by ratio of small integers. Spacing: FORMAT COMPACT Suppress extra line-feeds. FORMAT LOOSE Puts the extra line-feeds back in.

21. Bilangan complex

x=3+j*4; magx=abs(x); thetax=angle(x)*180/pi; disp(magx); disp(thetax)

>> 5

53.1301

>>

Page 20: No. 1

22. Matrix

A=[1 2 3; 0 1 4]; B=[2 3 0; -1 2 5]; A+B>> ans =

3 5 3 -1 3 9

>>

A=[1 2 3; 0 1 4]; B=[2 3 0; -1 2 5]; A-B

>> ans =

-1 -1 3 1 -1 -1

>>

Page 21: No. 1

k1=5; k2=(-3 + 2*j); A=[1 -2; 2 3]; k1*A>> ans =

5 -10 10 15

>>

k1=5; k2=(-3 + 2*j); A=[1 -2; 2 3]; k2*A

>> ans =

-3.0000 + 2.0000i 6.0000 - 4.0000i

Page 22: No. 1

-6.0000 + 4.0000i -9.0000 + 6.0000i

>>

23. Transformasi MatrixA=[ 1 2 3; 4 5 6]A'

>> A =

1 2 3 4 5 6

ans =

1 4 2 5 3 6

>>24. Fungsi Conj(x)

A = [1+2j j; 3 2-3j]conj_A=conj(A)

>> A =

1.0000 + 2.0000i 0 + 1.0000i 3.0000 2.0000 - 3.0000i

conj_A =

1.0000 - 2.0000i 0 - 1.0000i 3.0000 2.0000 + 3.0000i

Page 23: No. 1

>>

25. Determinan

A=[1 2; 3 4]; B=[2 -1; 2 0];det(A) det(B)

>> ans =

-2

ans =

2

>>

B=[2 -1 3; -4 -3 -2; 3 1 -1]; %delta=det(B); %d1=[5 -1 3; 8 -3 -2; 4 1 -1]; %detd1=det(d1); %d2=[2 5 3; -4 8 -2; 3 4 -1]; %detd2=det(d2); %d3=[2 -1 5; -4 -3 8; 3 1 4]; %detd3=det(d3);

Page 24: No. 1

v1=detd1/delta; %v2=detd2/delta; %v3=detd3/delta; %%disp('v1=');disp(v1); %disp('v2=');disp(v2); %disp('v3=');disp(v3);

>> v1= 2.4286

v2= -4.8571

v3= -1.5714

>>