Anda di halaman 1dari 16

PENGOLAHAN SINYAL

DIGITAL
Membangkitkan Sinyal Gelombang

DINDA AYU PERMATASARI, S.ST., M.T


Sinusoidal Signal Generation (1/4)
Pertimbangkan, untuk menghasilkan 64 sampel sinyal
sinusoidal frekuensi 1KHz, dengan frekuensi
pengambilan sampel 8KHz. Sinusoid sampel dapat
ditulis sebagai:
 f 
x(n)  A sin  2 n   
 fs 
di mana f adalah frekuensi sinyal, fs adalah frekuensi
sampling, θ adalah fase dan A adalah amplitudo sinyal.

2021/9/28 2
Sinusoidal Signal Generation (2/4)
% Generating 64 samples of x(t)=sin(2*pi*f*t) with a
% Frequency of 1KHz, and sampling frequency of 8KHz
N=64; % Define Number of samples
n=0:N-1; % Define vector n=0,1,2,3,...62,63
f=1000; % Define the frequency
fs=8000; % Define the sampling frequency
x=sin(2*pi*(f/fs)*n); % Generate x(t)
plot(n,x); % Plot x(t) vs. t
grid;
title('Sinewave [f=1KHz, fs=8KHz]');
xlabel('Sample Number');
ylabel('Amplitude');

2021/9/28 3
Sinusoidal Signal Generation (3/4)

2021/9/28 4
Sinusoidal Signal Generation (4/4)
Perhatikan bahwa ada 64 sampel dengan frekuensi
pengambilan sampel 8000Hz atau waktu pengambilan
sampel 0,125 mS (mis. 1/8000). Karenanya, panjang
rekam sinyal adalah 64x0.125 = 8mS. Tepatnya ada 8
siklus sinewave, menunjukkan bahwa periode satu
siklus adalah 1mS yang berarti bahwa frekuensi sinyal
adalah 1KHz.

2021/9/28 5
Exponential Signal Generation
(1/2)
Generating the signal x(t )  e 0.1t for t 0 to 40mS in
steps of 0.1mS.

% Generating the signal x(t)=exp(-0.1t)


t=0:0.1:40;
x=exp(-0.1*t);
plot(t,x);
grid;
title('Exponential Signal');
xlabel('Time [mS]');
ylabel('Amplitude');

2021/9/28 6
Exponential Signal Generation
(2/2)

2021/9/28 7
Unit Step Signal Generation (1/3)
A step signal is defined as follows:

2021/9/28 8
Unit Step Signal Generation (2/3)
% Generates 40 samples of a unit step signal,
u(n)
N=40; % Define the number of samples
n =-(N/2):((N/2)); % Define a suitable
discrete time axis
u=[zeros(1,(N/2)+1),ones(1,(N/2)]; % Generate
the signal
plot(n,u); % Plot the signal
axis([-20,+20,-0.5,1.5]); % Scale axis
grid;
title('A Unit Step Signal');
xlabel('Sample Number');
ylabel('Amplitude');

2021/9/28 9
Unit Step Signal Generation (3/3)

2021/9/28 10
Generating Random Signals
% Generates Uniformly and Normally Distributed random
signals
N=1024; % Define Number of samples
R1=randn(1,N); % Generate Normal Random Numbers
R2=rand(1,N); % Generate Uniformly Random Numbers
figure(1); % Select the figure
subplot(2,2,1); % Subdivide the figure into 4 quadrants
plot(R1); % Plot R1 in the first quadrant
grid;
title('Normal [Gaussian] Distributed Random Signal');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(2,2,2); % Select the second qudrant
hist(R1); % Plot the histogram of R1
grid;
11
Generating Random Signals
title('Histogram of a normal Random Signal');
xlabel('Sample Number');
ylabel('Total');
subplot(2,2,3);
plot(R2);
grid;
title('Uniformly Distributed Random Signal');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(2,2,4);
hist(R2);
grid;
title('Histogram of a uniformly Random Signal');
xlabel('Sample Number');
ylabel('Total');
2021/9/28 12
Generating Random Signals

2021/9/28 13
Generating Random Signals
Task: Generate 128 Uniformly random numbers
between -π to +π

2021/9/28 14
Sampling dengan Matlab
Contoh Program Matlab
t = [0:0.0001:2]; Fs = 20;
A = 5; Ts = 1/Fs;
F = 2; nTs = n*Ts;
xt = A*sin(2*pi*F*t); xn = A*sin(2*pi*F*nTs);
subplot(2,2,1); subplot(2,2,2);
plot(t,xt,'LineWidth',2);
axis([0 4*(1/F) -A A]) h3 = stem(n,xn,'.r','LineWidth',2);
xlabel('t(detik)'); axis([0 4*Fs/F -A A])
ylabel('x(t)'); xlabel('n(sample ke n), Ts=1/20
box('off'); detik');
grid('on'); ylabel('x(n)');
box('off');
n = [0:100]; grid('on');
Contoh Program Matlab

Anda mungkin juga menyukai