資源簡介
很好的函數自相關程序代碼,適合信號處理相干人士學習

代碼片段和文件信息
#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?????????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? {
????//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語言課程設計報告——通訊錄管理
評論
共有 條評論