0% found this document useful (0 votes)
35 views3 pages

Vignan Institute of Technology and Management: DSP Lab

The document contains code to generate and plot various signal processing functions including unit step, unit impulse, ramp, exponential, square, sine, and cosine functions. It also contains code demonstrating linear convolution using both the built-in conv function and a manual for loop method. Plots of the input, impulse response, and convolution result are displayed.

Uploaded by

tkpradhan
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)
35 views3 pages

Vignan Institute of Technology and Management: DSP Lab

The document contains code to generate and plot various signal processing functions including unit step, unit impulse, ramp, exponential, square, sine, and cosine functions. It also contains code demonstrating linear convolution using both the built-in conv function and a manual for loop method. Plots of the input, impulse response, and convolution result are displayed.

Uploaded by

tkpradhan
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/ 3

VIGNAN INSTITUTE OF TECHNOLOGY AND MANAGEMENT

DSP LAB
%unit Step function x=-5:1:10; y=[zeros(1,5) ones(1,11)]; subplot(4,2,1),stem(x,y); title('Unit step function'); xlabel('Time'),ylabel('Amplitude'); %Unit Impulse function x=-5:1:10; y=[zeros(1,5) 1 zeros(1,10)]; subplot(4,2,2),stem(x,y); title('Unit Impulse function'); xlabel('Time'),ylabel('Amplitude'); %Ramp function x=-5:1:10; y=x; subplot(4,2,3),bar(x,y); title('Ramp function'); xlabel('Time'),ylabel('Amplitude'); %Exponential function x=0:50; y=exp(x); subplot(4,2,4),stairs(x,y); title('Exponential function'); xlabel('Time'),ylabel('Amplitude'); %Square functions time = 0:0.0001:0.1; y = square(2*pi*50*time); %the signal have frequency of 50 Hz subplot(4,2,7),stem(time,y); title('Square functions'); xlabel('Time'),ylabel('Amplitude'); %Sine functions n=input('How many cycles you want'); angle=0:0.1:2*n*pi; y=sin(angle);

subplot(2,1,1),plot(angle,y); title('Sine functions'); xlabel('Angle'),ylabel('Amplitude'); %Cosine function n=input('How many cycles you want'); angle=0:0.1:2*n*pi; y=cos(angle); subplot(2,1,2),plot(angle,y); title('Cosine functions'); xlabel('Angle'),ylabel('Amplitude');

%Linear Convolution x=[1 2 2 1]; h=[2 3 1 4]; xl=length(x); hl=length(h); len=xl+hl-1; tl=1:xl; subplot(2,2,1),stem(tl,x); title('The Input function'); xlabel('x(n)'); tl=1:hl; subplot(2,2,2),stem(tl,h); title('The Impulse function'); xlabel('h(n)'); x=[x zeros(1,hl)]; h=[h zeros(1,xl)]; %Convolution using in-built convolution function y=[zeros(1,len)]; rsl=1:len; y=conv(x,h); subplot(2,2,3),stem(rsl,y); title('Result using conv function'); xlabel('y(n)'); %Convolution without using in-built convolution function Y=[zeros(1,len)];

for n=1:len s=0; for k=1:n s=s+(x(k)*h(n-k+1)); end Y(n)=s; end subplot(2,2,4),stem(rsl,Y); title('Result without using conv function'); xlabel('y(n)');

You might also like