资源简介
很好的函数自相关程序代码,适合信号处理相干人士学习
代码片段和文件信息
#include
#include
#include
#define NN 10
void xcorr(float *r unsigned short *x unsigned short *y int N);
int main()
{
unsigned short x[10]={1122345678};
unsigned short y[10]={1345678952};
float r[19] = {0};
FILE *fp_out;
int delay;
xcorr(r x y NN);
//Open the file to write
if((fp_out=fopen(“out_xcorr.txt““wt“)) == NULL)
{
printf(“Cannot open this file!\n“);
exit(0);
}
for(delay = -NN + 1; delay < NN; delay++)
fprintf(fp_out“%d %f\n“delayr[delay + NN - 1]);
fclose(fp_out);
system(“pause“);
return 0;
}
void xcorr(float *r unsigned short *x unsigned short *y int N)
{
float sxy;
int delayij;
for(delay = -N + 1; delay < N; delay++)
{
//Calculate the numerator
sxy = 0;
for(i=0; i {
j = i + delay;
if((j < 0) || (j >= N)) //The series are no wrappedso the value is ignored
continue;
else
sxy += (x[i] * y[j]);
}
//Calculate the correlation series at “delay“
r[delay + N - 1] = sxy;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 476814 2009-12-31 17:23 xcorr\cross_correlation.exe
文件 871 2009-12-31 17:34 xcorr\Makefile.win
文件 261 2009-12-31 17:34 xcorr\out_xcorr.txt
文件 1209 2009-12-31 17:28 xcorr\xcorr.c
文件 825 2009-12-31 17:28 xcorr\xcorr.dev
文件 17070 2009-12-31 17:34 xcorr\xcorr.exe
文件 1360 2009-12-31 17:34 xcorr\xcorr.o
目录 0 2009-12-31 17:34 xcorr
----------- --------- ---------- ----- ----
498410 8
- 上一篇:c语言实现双线性内插
- 下一篇:C语言课程设计报告——通讯录管理
评论
共有 条评论