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

Experiment No.1: %implementing Unit Impulse Function

The document describes experiments implementing and plotting various basic functions including unit impulse, unit step, and unit ramp functions. It also describes calculating the convolution sum for a linear time-invariant system by multiplying input and impulse response arrays to get a result matrix, then summing along diagonals to find the output array. Code is provided to accept user input for the arrays and perform the convolution calculation.

Uploaded by

gyugam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Experiment No.1: %implementing Unit Impulse Function

The document describes experiments implementing and plotting various basic functions including unit impulse, unit step, and unit ramp functions. It also describes calculating the convolution sum for a linear time-invariant system by multiplying input and impulse response arrays to get a result matrix, then summing along diagonals to find the output array. Code is provided to accept user input for the arrays and perform the convolution calculation.

Uploaded by

gyugam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

EXPERIMENT No.

1
%Implementing Unit Impulse Function
x = (-4:1:4);
y = [0 0 0 0 1 0 0 0 0];

subplot(2,1,1);
stem(x,y);
xlabel('X-axis');
ylabel('Y-axis');

subplot(2,1,2);
plot(x,y);
xlabel('X-axis');
ylabel('Y-axis');

%Implementing Unit Step Function


x = (-4:1:4);
y = [0 0 0 0 1 1 1 1 1];

subplot(2,1,1);
stem(x,y);
xlabel('X-axis');
ylabel('Y-axis');

subplot(2,1,2);
plot(x,y);
xlabel('X-axis');
ylabel('Y-axis');

%Implementing Unit Ramp Function

x = (-4:1:4);
y = [0 0 0 0 (0:1:4)];

subplot(2,1,1);
stem(x,y);
xlabel('X-axis');
ylabel('Y-axis');

subplot(2,1,2);
plot(x,y);
xlabel('X-axis');
ylabel('Y-axis');

%Implementing functions

x = (-4:1:4);

%Unit Impulse Function


y = [0 0 0 0 1 0 0 0 0];
subplot(3,2,1);

stem(x,y);
xlabel('X-axis');
ylabel('Y-axis');

subplot(3,2,2);
plot(x,y);
xlabel('X-axis');
ylabel('Y-axis');

%Unit Step Function


y1 = [0 0 0 0 1 1 1 1 1];
subplot(3,2,3);
stem(x,y1);
xlabel('X-axis');
ylabel('Y-axis');

subplot(3,2,4);
plot(x,y1);
xlabel('X-axis');
ylabel('Y-axis');

%Unit Ramp Function

y2 = [0 0 0 0 (0:1:4)];
subplot(3,2,5);
stem(x,y2);
xlabel('X-axis');
ylabel('Y-axis');

subplot(3,2,6);
plot(x,y2);
xlabel('X-axis');
ylabel('Y-axis');

EXPERIMENT No.2
%Implementing Convolution Sum For Linear Time Invariant
System

x = [1 2 3];
h = [1 2 1];

%function conv(x,h) for calculating result


stem(conv(x,h));

WAP to calculate convolution sum for LTI System

#include<stdio.h>

#include<conio.h>

int main()
{
clrscr();
int x[10],h[10],c[10][10];
int i,j,k,m,n;

printf("\n\n\t Enter the size of array 'x' :");


scanf("%d",&m);

printf("\n\t Enter the array elements : ");


for(i=0;i<m;i++)
scanf("%d",&x[i]);

printf("\n\n\t Enter the size of array 'h' :");


scanf("%d",&n);

printf("\n\t Enter the array elements : ");


for(i=0;i<n;i++)
scanf("%d",&h[i]);

printf("\n\n\t The Matrix is :\n\n\t");

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
c[i][j]=x[j]*h[i];
}

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf(" %d ",c[i][j]);
printf("\n\t");
}

int terms = m+n-1;


int y[10]={0};

for(k=0;k<m;k++)
{
for(j=0;j<n;j++)
y[k+j]=y[k+j]+c[k][j];

printf("\n\n\t Final Answer :: Convolution


Sum\n\n\t");

for(i=0;i<terms;i++)
printf("%d ",y[i]);

getch();
return 0 ;

You might also like