0% found this document useful (0 votes)
33 views

Tugas PJJ Week 10 Praktik Pengolahan Sinyal Digital: For If Else End End

The document contains MATLAB code for solving 5 signal processing problems. Each problem defines a signal x(n) or x(t) and provides the code to generate and plot the signal. The problems include operations like subtraction of delayed unit step functions, multiplication of a unit step by a decaying function, subtraction of delayed unit impulse functions, defining a piecewise function, and adding translated piecewise functions.

Uploaded by

Thareq Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Tugas PJJ Week 10 Praktik Pengolahan Sinyal Digital: For If Else End End

The document contains MATLAB code for solving 5 signal processing problems. Each problem defines a signal x(n) or x(t) and provides the code to generate and plot the signal. The problems include operations like subtraction of delayed unit step functions, multiplication of a unit step by a decaying function, subtraction of delayed unit impulse functions, defining a piecewise function, and adding translated piecewise functions.

Uploaded by

Thareq Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Tugas PJJ Week 10

Praktik Pengolahan Sinyal Digital

Soal 1

X1 [n] = U[n] – U[n-4]

Kodingan
clear
clc
n = -5 : 1 : 5
for i = 1:length(n)
if (n(i) < 0)
u(i) = 0
else
u(i) = 1
end
end
subplot(3,1,1)
stem(n,u,'-g','linewidth',2);
title('u(n)')
xlabel('n')
ylabel('Amplitudo')
for i = 1:length(n)
if (n(i)-4 < 0)
u1(i) = 0
else
u1(i) = 1
end
end
subplot(3,1,2)
stem(n,u1,'o','linewidth',2);
title('u(n-4)')
xlabel('n')
ylabel('Amplitude')
% x1(n) = u(n) - u(n-4)
for i = 1:length(n)
x1(i) = u(i) - u1(i);
end
subplot(3,1,3)
stem(n,x1,'r','linewidth',2);
title('x1(n) = u(n) - u(n-4)')
xlabel('n')
ylabel('Amplitude')
Hasil

Soal 2

x2(n) = (1/2)n. u(n-3)

Kodingan
clear
clc
n = -10:10;
for i = 1:length(n)
if (n(i)-3 >= 0)
u(i) = 1;
else
u(i) = 0;
end
end
subplot(2,1,1);
stem(n,u,'or','linewidth',2);
title('u[n-3]');
for i = 1:length(n)
x(i) = (1/2).^i .* u(i);
end
subplot(2,1,2);
stem(n,x,'c','linewidth',2);
title('x[n] = (1/2)^n * u[n-3]');
Hasil
Soal 3

x(n)= d(n+2) - d(n-2)

Kodingan
clear
clc
n=-7:1:7;
for i=1:length(n)
if n(i)+2==0
d1(i)=0
else
d1(i)=1
end
end
subplot(3,1,1)
stem(n,d1,'-or'), title('d(n+2)')
for i=1:length(n)
if n(i)-2==0
d2(i)=1
else
d2(i)=0
end
end
subplot(3,1,2)
stem(n,d2,'-g'), title('d(n-2)')
for i=1:length(n)
y(i)=d1(i)-d2(i);
end
subplot(3,1,3)
stem(n,y,'-b'), title('y(i)=d1(i)-d2(i)')

Hasil
Soal 4

x(t) = 0 ≤ t ≤ 1 = 1

x(t) = 1 < t < 4 = −2

Kodingan
clear
clc
t = -10:0.1:10;
for i = 1:length(t)
if (t(i)>=0 & t(i)<= 1)
d(i) = 1;
elseif (t(i)>1 & t(i)< 2)
d(i) = -2
else d(i)=0;
end
end
plot(t,d,'-g','linewidth',2);
title('x(t)')

Hasil
Soal 5

x(1-t) + x(2-t)

Kodingan
clear
clc
t = -10:.1:10;
for i = 1:length(t)
if (1-t(i) >= 0 && 1-t(i) <= 1)
x(i) = 1;
elseif (1-t(i) > 1 && 1-t(i) < 5)
x(i) = -3;
else
x(i) = 0;
end
end
subplot(3,1,1);
plot(t,x,'-c','linewidth',2);
title('x[1-t]');
for i = 1:length(t)
if (2-t(i) >= 0 && 2-t(i) <= 1)
x1(i) = 1;
elseif (2-t(i) > 1 && 2-t(i) < 5)
x1(i) = -3;
else
x1(i) = 0;
end
end
subplot(3,1,2);
plot(t,x1,'-g','linewidth',2);
title('x[2-t]');
for i = 1:length(t)
y(i) = x(i) - x1(i);
end
subplot(3,1,3);
plot(t,y,'-b','linewidth',2);
title('y[t] = x[1-t] - x[2-t]');

Hasil

You might also like