浓毛老太交欧美老妇热爱乱,蜜臀性色av免费,妺妺窝人体色www看美女,久久久久久久久久久大尺度免费视频,麻豆人妻无码性色av专区

位置:51電子網(wǎng) » 技術(shù)資料 » EDA/PLD

vc中幾個(gè)數(shù)字信號(hào)處理算法程序

發(fā)布時(shí)間:2008/8/23 0:00:00 訪問次數(shù):456

  摘要:在學(xué)習(xí)數(shù)字信號(hào)處理算法程序中用vc編寫的幾個(gè)通用算法程序。

  在學(xué)習(xí)信號(hào)處理的過程中,看到書上的大部分算法都是用fortan或者basic實(shí)現(xiàn),于是自己試驗(yàn)著用vc實(shí)現(xiàn)了一下。

1、卷積計(jì)算

  離散卷積公式的算法實(shí)現(xiàn)


  圖1 卷積計(jì)算界面

1.1 主程序代碼(省略了部分不關(guān)鍵代碼)

void cintervolvedlg::calthenumbyarray() { this->updatedata(true);
ffuncs funcs[2] = {funch1,funch2};
int n = this->m_valuen; double* x = new double[2*(n+1)];
//x(n) double* y = new double[2*(n+1)];
//y(n) double* h = new double[2*(n+1)];
//h(n)
//1.init x(n),h(n),y(n) cbutton* pbtn = (cbutton*) this->getdlgitem(idc_radio1);
int nchoseitem = 0;
//函數(shù)選擇 if(pbtn->getcheck()) { nchoseitem = 0; } e
lse { nchoseitem = 1; } for(int i= 0;i<2*(n+1);i++) { if(i< n+1) { x[i] = 1; h[i] = funcs[nchoseitem](i); }
else { x[i] = 0; h[i] = 0; } }
//2.y(i)=sum(x(m)*h(i-m)) m=0..i for(i=0;i<2*(n+1);i++) { y[i] = calcy(x,h,i); }
//顯示結(jié)果 delete[] x; delete[] y; delete[] h;}

1.2 各個(gè)子函數(shù)實(shí)現(xiàn)

typedef double (* ffuncs)(int);
//h1(x) doublefunch1(intn) { doublefbase = (double)4/(double)5; double fr = std::pow(fbase, n); return fr; }
//h2(x)doublefunch2(intn) { doublefpi = 3.1415927; return 0.5*sin((double)0.5*n); }
//y(n)//y(n)=sum(x(m)*y(n-m))m=0..n doublecalcy(double x[],double h[],int n) {double yvalue = 0;
for(int m= 0;m<=n;m++) { yvalue += x[m]*h[n-m]; }
return yvalue;}

2、dft與fft實(shí)現(xiàn)

程序界面,具體實(shí)現(xiàn)見注釋及代碼:


圖2 dft與fft實(shí)現(xiàn)界面

2.1 主程序代碼

void cfftconversiondlg::onbnclickedbtncal() { this->updatedata(true);
int nn = this->m_numn;
float ff = this->m_numf;
float ft = this->m_numt;
bool bistimesof2 = false;
for(int i= 0;i<100;i++) { if(nn==(2 < < i)) { bistimesof2 = true; break; } }
if(!bistimesof2) { afxmessagebox("n請輸入一個(gè)以2為底的冪級(jí)數(shù)!");
this->getdlgitem(idc_edtn)->setfocus();
return; } comp* x = new comp[nn];
//x(n) comp* x = new comp[nn];//x(k) initx(nn,x,ff,ft);
cbutton* pradio = (cbutton*)this->getdlgitem(idc_radiodft);
if(pradio->getcheck()) { dft(nn,x,x); }
else { fft(nn,x,x); }
char buffer[256];
comp source = x[nn-1];
sprintf(buffer,"%f+%fi",source.real(),source.imag());
cwnd* pwnd = this->getdlgitem(idc_edtret);
pwnd->setwindowtext(buffer);
clistctrl* plist=(clistctrl*) this->getdlgitem(idc_list1);
clistoper oper;
oper.filllist(*plist,nn,x,x);
delete[] x;
delete[] x;}

2.2 子函數(shù)代碼

說明:其中comp為復(fù)數(shù)類型

/*******************************************
name :dft* function
:disperse fuliye transformation* params
:n -- total count of sampling points* x -- input sequence* return
:xn(k)=sum[x(n)*pow(e,j2*pi/n)]
* k,n
:0..n-1
*******************************************
/void dft(int n,comp x[],comp xk[]){ double c = (2*pi)/n;
comp t(0,0),ret(0,0);
for(int k=0;k < n;k++)
{ ret = comp(0,0);
for(int i=0;i< n;i++) { t = comp(cos(c*k*i),-sin(c*k*i));
ret += x[i]*t; } xk[k] = ret; } }/
*******************************************
name
:fft* function
:fast fuliye transformation* params
:n -- total count of sampling points* x -- input sequence* return
:xn(k)=sum[x(n)*pow(e,j2*pi/n)] * k,n
:0..n-1
*******************************************
/void fft(int n,comp x[],comp xk[]){ int j=0; comp u=0,w=0;
comp* a = xk;
//adjust sequence for(int i=0;i< n;i++) { if(i==0) { a[0] = x[0]; }
else { j=getinverse(n,j);
a[i] = x[j]; } }
//確定級(jí)別數(shù)
for(int m=0;m< n;m++) { if((1<< m)==n) break; }
for(int l=1;l<=m;l++)//1-m

  摘要:在學(xué)習(xí)數(shù)字信號(hào)處理算法程序中用vc編寫的幾個(gè)通用算法程序。

  在學(xué)習(xí)信號(hào)處理的過程中,看到書上的大部分算法都是用fortan或者basic實(shí)現(xiàn),于是自己試驗(yàn)著用vc實(shí)現(xiàn)了一下。

1、卷積計(jì)算

  離散卷積公式的算法實(shí)現(xiàn)


  圖1 卷積計(jì)算界面

1.1 主程序代碼(省略了部分不關(guān)鍵代碼)

void cintervolvedlg::calthenumbyarray() { this->updatedata(true);
ffuncs funcs[2] = {funch1,funch2};
int n = this->m_valuen; double* x = new double[2*(n+1)];
//x(n) double* y = new double[2*(n+1)];
//y(n) double* h = new double[2*(n+1)];
//h(n)
//1.init x(n),h(n),y(n) cbutton* pbtn = (cbutton*) this->getdlgitem(idc_radio1);
int nchoseitem = 0;
//函數(shù)選擇 if(pbtn->getcheck()) { nchoseitem = 0; } e
lse { nchoseitem = 1; } for(int i= 0;i<2*(n+1);i++) { if(i< n+1) { x[i] = 1; h[i] = funcs[nchoseitem](i); }
else { x[i] = 0; h[i] = 0; } }
//2.y(i)=sum(x(m)*h(i-m)) m=0..i for(i=0;i<2*(n+1);i++) { y[i] = calcy(x,h,i); }
//顯示結(jié)果 delete[] x; delete[] y; delete[] h;}

1.2 各個(gè)子函數(shù)實(shí)現(xiàn)

typedef double (* ffuncs)(int);
//h1(x) doublefunch1(intn) { doublefbase = (double)4/(double)5; double fr = std::pow(fbase, n); return fr; }
//h2(x)doublefunch2(intn) { doublefpi = 3.1415927; return 0.5*sin((double)0.5*n); }
//y(n)//y(n)=sum(x(m)*y(n-m))m=0..n doublecalcy(double x[],double h[],int n) {double yvalue = 0;
for(int m= 0;m<=n;m++) { yvalue += x[m]*h[n-m]; }
return yvalue;}

2、dft與fft實(shí)現(xiàn)

程序界面,具體實(shí)現(xiàn)見注釋及代碼:


圖2 dft與fft實(shí)現(xiàn)界面

2.1 主程序代碼

void cfftconversiondlg::onbnclickedbtncal() { this->updatedata(true);
int nn = this->m_numn;
float ff = this->m_numf;
float ft = this->m_numt;
bool bistimesof2 = false;
for(int i= 0;i<100;i++) { if(nn==(2 < < i)) { bistimesof2 = true; break; } }
if(!bistimesof2) { afxmessagebox("n請輸入一個(gè)以2為底的冪級(jí)數(shù)!");
this->getdlgitem(idc_edtn)->setfocus();
return; } comp* x = new comp[nn];
//x(n) comp* x = new comp[nn];//x(k) initx(nn,x,ff,ft);
cbutton* pradio = (cbutton*)this->getdlgitem(idc_radiodft);
if(pradio->getcheck()) { dft(nn,x,x); }
else { fft(nn,x,x); }
char buffer[256];
comp source = x[nn-1];
sprintf(buffer,"%f+%fi",source.real(),source.imag());
cwnd* pwnd = this->getdlgitem(idc_edtret);
pwnd->setwindowtext(buffer);
clistctrl* plist=(clistctrl*) this->getdlgitem(idc_list1);
clistoper oper;
oper.filllist(*plist,nn,x,x);
delete[] x;
delete[] x;}

2.2 子函數(shù)代碼

說明:其中comp為復(fù)數(shù)類型

/*******************************************
name :dft* function
:disperse fuliye transformation* params
:n -- total count of sampling points* x -- input sequence* return
:xn(k)=sum[x(n)*pow(e,j2*pi/n)]
* k,n
:0..n-1
*******************************************
/void dft(int n,comp x[],comp xk[]){ double c = (2*pi)/n;
comp t(0,0),ret(0,0);
for(int k=0;k < n;k++)
{ ret = comp(0,0);
for(int i=0;i< n;i++) { t = comp(cos(c*k*i),-sin(c*k*i));
ret += x[i]*t; } xk[k] = ret; } }/
*******************************************
name
:fft* function
:fast fuliye transformation* params
:n -- total count of sampling points* x -- input sequence* return
:xn(k)=sum[x(n)*pow(e,j2*pi/n)] * k,n
:0..n-1
*******************************************
/void fft(int n,comp x[],comp xk[]){ int j=0; comp u=0,w=0;
comp* a = xk;
//adjust sequence for(int i=0;i< n;i++) { if(i==0) { a[0] = x[0]; }
else { j=getinverse(n,j);
a[i] = x[j]; } }
//確定級(jí)別數(shù)
for(int m=0;m< n;m++) { if((1<< m)==n) break; }
for(int l=1;l<=m;l++)//1-m

相關(guān)IC型號(hào)

熱門點(diǎn)擊

 

推薦技術(shù)資料

聲道前級(jí)設(shè)計(jì)特點(diǎn)
    與通常的Hi-Fi前級(jí)不同,EP9307-CRZ這臺(tái)分... [詳細(xì)]
版權(quán)所有:51dzw.COM
深圳服務(wù)熱線:13751165337  13692101218
粵ICP備09112631號(hào)-6(miitbeian.gov.cn)
公網(wǎng)安備44030402000607
深圳市碧威特網(wǎng)絡(luò)技術(shù)有限公司
付款方式


 復(fù)制成功!