Umal-qura university



Yüklə 0,73 Mb.
səhifə26/30
tarix23.12.2023
ölçüsü0,73 Mb.
#156716
1   ...   22   23   24   25   26   27   28   29   30
Signal and Systems Manual - v2full

Amplitude Clipping

clear
x=[3 4 4 2 1 ‐4 4 ‐2];
len=length(x); y=x;
hi=3;
lo=‐3;
for i=1:len
if(y(i)>hi)
y(i)=hi; elseif(y(i)y(i)=lo;
end
end
subplot(2,1,1);
stem(x,'filled'); title('original signal'); xlabel('Sample number'); ylabel('Signal Amplitude');

subplot(2,1,2);


stem(y,'filled'); title('Clipped Signal'); xlabel('Sample number'); ylabel('Signal Amplitude');
79
Department of Computer





      1. Signal Replication

clear
x=[1 2 3 2 1];


y=[x x x x]; subplot(2,1,1);
stem(x,'filled'); title('Original Signal'); xlabel('Sample Number'); ylabel('Signal Amplitude'); axis([1 20 0 3]);
grid;

subplot(2,1,2);


stem(y,'filled'); title('Replicated Signal');
80
Department of Computer Engineering Umm Al Qura University, Makkah
xlabel('Sample Number'); ylabel('Signal Amplitude'); axis([1 20 0 3]);
grid;

81
Department of Computer Engineering Umm Al Qura University, Makkah




Lab # 8


82
Department of Computer Engineering Umm Al Qura University, Makkah




OBJECTIVES OF THE LAB

This lab aims at the understanding of:





  • Making Signals Causal and Non‐Causal

  • Convolution





    1. MAKING SIGNALS CAUSAL AND NON-CAUSAL

Causal Signals: A signal is said to be causal if it is zero for time t<0. A signal can be made causal by multiplying it with unit step.


Example

clc clear all close all


t= ‐2:1/1000:2; x1


= sin(2*pi*2*t);

subplot(3,1,1); plot(t,x1,'LineWidth',2); xlabel('time'); ylabel('signal amplitude'); title('sin(2*\pi*f*t)');


u = (t>=0);


x2 = x1.*u;

subplot(3,1,2);


plot(t,u, 'r','LineWidth',2); xlabel('time'); ylabel('Signal Amplitude'); title('Unit Step');

subplot(3,1,3);


plot(t,x2, 'k','LineWidth',2); xlabel('time'); ylabel('signal amplitude');
title('causal version of sin(2*\pi*f*t)');

figure;
plot(t,x1,t,u,'‐.',t,x2,'LineWidth',2);


text(0,1.2,'u(t)','FontSize',16);
text(‐1.2,‐1.1,'x(t)','FontSize',16);
text(0.8,‐1.1,'x(t)*u(t)','FontSize',16); axis([‐2 2 ‐1.5 1.5]);





    1. CONVOLUTION

Use the matlab command conv(h, x) to find convolution where h – impulse response


x – input signal


Example

clc clear all close all


h = [1 2 3 4 5 4 3 2 1];


x = sin(0.2*pi*[0:20]);
y = conv(h, x);

figure(1); stem(x);


title('Discrete Filter Input x[n]'); xlabel('index, n'); ylabel('Value, x[n]');

figure(2); stem(y, 'r');


title('Discrete Filter Output y[n]'); xlabel('index, n'); ylabel('Value, y[n]');



Even though there are only 21 points in the x array, the conv function produces 8 more points because it uses the convolution summation and assumes that x[n] = 0 when n>20.




TASK 1
Convolve the following
signals: x =[2 4 6 4 2];
h =[3 ‐1 2 1];
Plot the input signal as well as the output signal.



Yüklə 0,73 Mb.

Dostları ilə paylaş:
1   ...   22   23   24   25   26   27   28   29   30




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə