Program-program MatLab yang dipakai dalam catatan kuliah
Menggambar sinyal diskret eksponensial sinusoidal x[n] = zn.
function sl03disk % menggambar sinyal diskret eksponensial sinusoidal
n=0:30;
z=0.9-0.2j; C = 1+j;
figure(1); clf;
stem(n, real(C*z.^n), 'filled'); title('oleh HT @ Elen UMS');
text(3,17,sprintf('y = z^{n} ; z = %s',num2str(z)),'FontName','Courier');
Menggambar sinyal u[n] dan d[n].
function sl03disko2 %Menggambar sinyal diskret tangga dan impuls satuan
n=-10:20;
figure(1);set(gcf,'Position',[0 0 420 160]); clf;
stem(n, u(n),'filled'), axis ([-inf inf -2 2]); title('oleh HT @ Elen UMS');
text(-7,1.6, 'y = u(n)','FontName','Courier');
figure(2);set(gcf,'Position',[400 0 420 160]); clf;
stem(n, del(n),'filled'), axis ([-inf inf -2 2]);title('oleh HT @ Elen UMS');
text(-7,1.6, 'y = \delta(n)','FontName','Courier');
function [y]=u(x)
[y] = (2+sign(x)-sign(abs(x)))/2;
function [y]=del(x)
[y] = (1-sign(abs(x)));
Menggambar sinyal kontinyu eksponensial sinusoidal x(t) = Ceat.
function sl03 % menggambar sinyal kontinyu eksponensial sinusoidal
t=linspace(-2,4,1000);
a=-1+10j; C = 1;
figure(1); clf;
plot(t, real(C*exp(a*t))); title('oleh HT @ Elen UMS');
text(-1.8,7, sprintf('y = Ce^{at} a = %s',num2str(a)),'FontName','Courier');
hold on;plot(t, real(C*exp(real(a)*t)),'k:');
hold on;plot(t, -real(C*exp(real(a)*t)),'k:');
Menggambar sinyal u(t) dan d(t).
t=linspace(-2,2,1001);
figure(2); set(gcf,'Position',[0 0 420 160]); clf;
plot(t, u(2*t-1)), axis ([-inf inf -2 2]); title('oleh HT @ Elen UMS');
text(-1,1, 'y = u(2t-1)','FontName','Courier');
figure(3); set(gcf,'Position',[400 0 420 160]); clf;
plot(t, del(t)), axis ([-inf inf -2 2]);title('oleh HT @ Elen UMS');
text(-1,1, 'y = \delta(t)','FontName','Courier');
function [y]=u(t)
[y] = (2+sign(t)-sign(abs(t)))/2;
function [y]=del(x)
[y] = (1-sign(abs(x)));
Menggambar sinyal x(t) = Ceatu(t).
function sl03
t=linspace(-2,4,1000);
a=-1+4j; C = 1+j;
figure(1); clf;
plot(t, real(C*exp(a*t)).*u(t));title('oleh HT @ Elen UMS');
text(-1.8,0.7, sprintf('y = Ce^{at}u(t) a = %s',num2str(a)),'FontName','Courier');
function [y]=u(t)
[y] = (sign(t)+sign(abs(t)))/2;
Menggambar sinyal x(t) dan x(2t), dan juga sinyal-sinyal hasil operasi matematis
lain terhadap x(t). Modifikasi pada baris ke-6 dan ke-7 diperlukan untuk menggambar sinyal
hasil operasi matematis lain.
function sl03opmat %Menggambar sinyal x(t) dan x(2t)
t=linspace(-5,10,1000); xtk=[-2 0 2 3];
figure(1);clf;
subplot(1,2,1);plot(t, x(t)),text(4,1.5,'x(t)','FontName','Courier'),axis([-5 10 -1 5]);title('oleh HT @ Elen UMS');
set(gca,'xtick',xtk,'FontName','Courier');
subplot(1,2,2);plot(t, x(2*t)),text(4,1.5,'x(2t)','FontName','Courier'),axis([-5 10 -1 5]);
set(gca,'xtick',[-1 0 1 2],'FontName','Courier');
function [y]=x(t)
y=0*t;
for k=1:length(t),y(k)=f(t(k)); end;
function y=f(t)
if and(t>=-2,t < 0), y=2; elseif and(t >= 0,t < 2), y=2-t/2;
elseif and(t >= 2,t < 3), y=1; else y=0; end;
Menggambar Pole-Zero Plot untuk contoh 1 sampai contoh 4 bab Pole Zero Plot
dan Bode Plot. Perhatikan perintah tf. Perintah ini digunakan untuk membentuk sistem
linier dengan transfer function. Format perintah adalah tf(num,den) di mana num=numerator
dan den=denominator.
H1=tf(1,[1 2]);; subplot(221); %H1(s)=1/(s+2)
plot(real(pole(H1)),imag(pole(H1)),'b*',real(zero(H1)),imag(zero(H1)),'ro');title('oleh HT @ Elen UMS');
axis([-3 3 -3 3]), grid; text(0.2,1,'contoh 1'); text(3,3.5,'Pole Zero Plot')
H2=tf([1 0],[1 -0.7]); subplot(222); %H2(z)=z/(z-0.7)
plot(real(pole(H2)),imag(pole(H2)),'b*',real(zero(H2)),imag(zero(H2)),'ro');
axis([-3 3 -3 3]), grid; text(0.2,1,'contoh 2');
H3=tf(5,[1 2 0]); subplot(223); %H3(s)=5/(s^2+2s)
plot(real(pole(H3)),imag(pole(H3)),'b*',real(zero(H3)),imag(zero(H3)),'ro');
axis([-3 3 -3 3]), grid; text(0.2,1,'contoh 3');
H4=tf([1 2],[1 2 5]); subplot(224); %H4(s)=(s+2)/(s^2+2s+5)
plot(real(pole(H4)),imag(pole(H4)),'b*',real(zero(H4)),imag(zero(H4)),'ro');
axis([-3 3 -3 3]), grid; text(0.2,1,'contoh 4');
Menggambar Bode plot
H=tf(1,[1 1]);
bode(H);title('oleh HT @ Elen UMS');