I would like to write blogs which contains programs in C
language or of MATLAB code.The reason is simple,I have a subject called
Digital signal processing laboratory.It contains totally 24 programs and
in exam we need to write just two,so some programs which I like out of
the remaining ones I would like to write them in my blogs.
C program :
#include<stdio.h>
main();
{
float y[16],w;
float x[4]={1,3,2,5};
int n,k,k1,N=8,xlen=4;
for(k=0;k<2*N;k=k+2)
{
y[k]=0;
y[k+1]=0;
k1=k/2;
for(n=0;n<xlen;n++)
{
w=-2*3.14*k1*n/N;
y[k]=y[k]+x(n)*cos(w);
y[k+1]=y[k+1]+x(n)*sin(w);
}
}
printf("%f+j%F",y[k],y[k+1]);
}
C program :
#include<stdio.h>
main();
{
float y[16],w;
float x[4]={1,3,2,5};
int n,k,k1,N=8,xlen=4;
for(k=0;k<2*N;k=k+2)
{
y[k]=0;
y[k+1]=0;
k1=k/2;
for(n=0;n<xlen;n++)
{
w=-2*3.14*k1*n/N;
y[k]=y[k]+x(n)*cos(w);
y[k+1]=y[k+1]+x(n)*sin(w);
}
}
printf("%f+j%F",y[k],y[k+1]);
}
No comments:
Post a Comment