You are on page 1of 2

#include <math.

h>
int i=0;
int j=0;
//L=M+N-1
//30+30-1=59
float h1[59]={0};
float h2[59]={0};
int u[59]={0};
float y1[59]={0};
float y2[59]={0};
int n=0;
void main(void)
{

for (n=0;n<30;n++)
{
h1[n]= pow((0.8),n);
}

for (n=0;n<30;n++)
{
h2[n]= 2.5*pow(0.5,n) - 1.5*pow(0.3,n);
}

for (n=0;n<30;n++)
{
u[n]=1;
}

for(i=0;i<59;i++)
{
y1[i]=0;
for(j=0;j<=i;j++)
{
y1[i]+= (u[i-j]*h1[j]);
}

for(i=0;i<59;i++)
{
y2[i]=0;
for(j=0;j<=i;j++)
{
y2[i]+= (u[i-j]*h2[j]);
}

}
}

//MATLAB
n=0:29;
h1= 0.8.^n
h2=2.5*(0.5).^n - 1.5*(0.3).^n

u=n>=0;

y1=conv(u,h1)
subplot(211)
stem(h1)
subplot(212)
stem(y1)
y2=conv(u,h2)
figure
subplot(211)
stem(h2)
subplot(212)
stem(y2)

You might also like