0% found this document useful (0 votes)
97 views7 pages

Unit Impulse

The document describes various operations that can be performed on signals including: 1) Creating basic signal sequences like unit impulse, unit step, sinusoidal, square wave, sawtooth wave and exponential signals. 2) Performing operations on signals like addition, scaling, shifting, folding, sample summation and sample multiplication. 3) Plotting the signals to visualize and compare the results of these operations.

Uploaded by

haque2008
Copyright
© Attribution Non-Commercial (BY-NC)
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)
97 views7 pages

Unit Impulse

The document describes various operations that can be performed on signals including: 1) Creating basic signal sequences like unit impulse, unit step, sinusoidal, square wave, sawtooth wave and exponential signals. 2) Performing operations on signals like addition, scaling, shifting, folding, sample summation and sample multiplication. 3) Plotting the signals to visualize and compare the results of these operations.

Uploaded by

haque2008
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 7

% Unit impulse. %Create single impulse between finite no of zeros.

n=[-5:5]; x=[n==0]; stem(n,x); title('Unit impulse sequence'); xlabel('n'); ylabel('(xn)'); ylim([-2,2]); % Unit step sequence. n=[-5:5]; x=[n>=0]; %'>='Greater then or Equal to. stem(n,x); title('Unit step sequence'); xlabel('n'); ylabel('(xn)'); %'=='Equal to.

% sinusoidal sequence . %To generate, sin(0.2pin),0<=n<=100. t=0:0.001:2; f=5; x=sin(2*pi*f*t); plot(t,x);

% Square wave genration. t=[0:0.1:2]; sqw1=square(2*pi*2*t); plot(t,sqw1); ylim([-2,2]); %ylim([ymin ymax]) sets the axis limits in the current axes to the specified values. title('Square wave'); % Square wave genration. t=[0:0.01:2]; sqw1=square(2*pi*2*t); subplot(2,1,1); plot(t,sqw1); ylim([-2,2]); %ylim([ymin ymax]) sets the axis limits in the current axes to the specified values. title('Square wave'); t=[0:0.1:2]; sqw2=square(2*pi*2*t,75); subplot(2,1,2); plot(t,sqw2); ylim([-2,2]); %ylim([ymin ymax]) sets the axis limits in the current axes to the specified values.

title('Square wave with 75% duty cycle'); % Saw-tooth and triangular wave generation. t=[0:0.01:2]; saw1=sawtooth(2*pi*3*t); subplot(2,1,1); plot(t,saw1); ylim([-2,2]); %ylim([ymin ymax]) sets the axis limits in the current axes to the specified values. title('sawtooth wave'); subplot(2,1,2); saw2=sawtooth(2*pi*3*t,1/2); plot(t,saw2); ylim([-2,2]); %ylim([ymin ymax]) sets the axis limits in the current axes to the specified values. title('Triangular wave'); %Real exponential sequence. %To generate x(n)=(0.9)^n;. n=[0:10]; 0<=n<=10; x=(0.9).^n; plot(n,x) title('Real exponential sequence');

%To generate x(n)=Exp[2n]. n=[0:10]; 0<=n<=10;

x=exp(2*n); plot(n,x) title('Real exponential sequence'); %Step reponse of frist order system. t=0:0.1:10; tow=0.3; x=1-exp(-t/tow); plot(t,x); title('Step reponse of frist order system'); xlabel('t'); ylabel('x(t)'); ylim([0,2]); % Periodic sequence %A sequence is periodic if x(n)=x(n+N). %To genrate p period of x(n) from one period ,we can copy x(n)p time. %xtilde=[x,x,x,x,x]; x=[0 1 1.5 1 0 0 1 2 3 4 3 2 1 -1 -1.5 -1 0 0 0.5 0 0 0]; x1=[x,x,x,x,x,x,x]; subplot(2,1,1); plot(x1); x2=[x,x,x,x,x]; subplot(2,1,2); plot(x2);

% BASIC OPERATION ON SIGNAL.


% Signal addition.

% To add tow sequence x1(n) and x2(n) require operation "+". % But the length of both sequence must be equal have the same sample % position. y1=[10 10 10 10 10] n1=1:5; y2=[1 2 3 4 5] n2=1:5; n=1:5; y=y1+y2; subplot(3,1,1); stem(n,y1); subplot(3,1,2); stem(n,y2); subplot(3,1,3); stem(n,y); Signal scaling. % each sample is multiplied by scalar use the command "*" for scaling. y1=[2 5 6 1 4] n=2:6 y=2.5*y1 subplot(3,1,1) stem(n,y) subplot(3,1,2) stem(n,y1) ylim([0,20]) xlim([0,8]) % Signal shifting.

% Each sample of x(n) is shifted by an amount k to obtain shifted sequence % y(n). % Right shift: y(m)=x(m-k) % Left shift: y(m)=x(m+k) x=[2 5 6 1 4]; n=2:6; % Right shift by 3 samples y(m). m=n+3; y=x; % Left shift by 1 sample z(t) t=n-1 z=x subplot(3,1,1); stem(n,x); xlim([0,10]); subplot(3,1,2); stem(m,y); xlim([0,10]); subplot(3,1,3); stem(t,z); xlim([0,10]); %folding. % Implemanted by "fliplr(x)" x=[2 5 6 1 4] n=2:6 y=-fliplr(x) subplot(2,1,1) stem(n,x) xlim([0,10])

subplot(2,1,2) stem(n,y) xlim([0,10])

%Sample summation %add all sample value of x(n)between n1 & n2 % implementation by "sum(x(n1:n2)) x=[2 5 6 1 4] sx=sum(x(1:5)) %Sample multiplication %multiplies all sample value of x(n)between n1 & n2 % implementation by "prod(x(n1:n2)) x=[2 5 6 1 4] sx=prod(x(1:5))

You might also like