欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

c語(yǔ)言dft函數(shù),df是什么函數(shù)

DTFT和DFT區(qū)別是什么

DTFT, DFT 的區(qū)別是含義不同、性質(zhì)不同、用途不同。

創(chuàng)新互聯(lián)主打移動(dòng)網(wǎng)站、成都做網(wǎng)站、成都網(wǎng)站制作、網(wǎng)站改版、網(wǎng)絡(luò)推廣、網(wǎng)站維護(hù)、域名注冊(cè)、等互聯(lián)網(wǎng)信息服務(wù),為各行業(yè)提供服務(wù)。在技術(shù)實(shí)力的保障下,我們?yōu)榭蛻?hù)承諾穩(wěn)定,放心的服務(wù),根據(jù)網(wǎng)站的內(nèi)容與功能再?zèng)Q定采用什么樣的設(shè)計(jì)。最后,要實(shí)現(xiàn)符合網(wǎng)站需求的內(nèi)容、功能與設(shè)計(jì),我們還會(huì)規(guī)劃穩(wěn)定安全的技術(shù)方案做保障。

1、含義不同:DTFT是離散時(shí)間傅里葉變換,DFT是離散傅里葉變換。

2、性質(zhì)不同:DTFT變換后的圖形中的頻率是一般連續(xù)的(cos(wn)等這樣的特殊函數(shù)除外,其變換后是沖擊串),而DFT是DTFT的等間隔抽樣,是離散的點(diǎn)。

3、用途不同:DFT完全是應(yīng)計(jì)算機(jī)技術(shù)的發(fā)展而來(lái)的,因?yàn)槿绻麤](méi)有計(jì)算機(jī),用DTFT分析看頻率響應(yīng)就可以,為了適應(yīng)計(jì)算機(jī)計(jì)算,那么就必須要用離散的值,因?yàn)橛?jì)算機(jī)不能處理連續(xù)的值。

參考資料來(lái)源:

百度百科-DTFT

百度百科-DFT

dft這個(gè)函數(shù)什么意思

這是dft變換的函數(shù)呀~~你找個(gè)信號(hào)處理,和數(shù)字?jǐn)?shù)字信號(hào)處理 看看dft變換在含義和使用方法就能知道怎么用了

求FFT的c語(yǔ)言程序

快速傅里葉變換 要用C++ 才行吧 你可以用MATLAB來(lái)實(shí)現(xiàn)更方便點(diǎn)啊

此FFT 是用VC6.0編寫(xiě),由FFT.CPP;STDAFX.H和STDAFX.CPP三個(gè)文件組成,編譯成功。程序可以用文件輸入和輸出為文件。文件格式為T(mén)XT文件。測(cè)試結(jié)果如下:

輸入文件:8.TXT 或手動(dòng)輸入

8 //N

1

2

3

4

5

6

7

8

輸出結(jié)果為:或保存為T(mén)XT文件。(8OUT.TXT)

8

(36,0)

(-4,9.65685)

(-4,4)

(-4,1.65685)

(-4,0)

(-4,-1.65685)

(-4,-4)

(-4,-9.65685)

下面為FFT.CPP文件:

// FFT.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。

#include "stdafx.h"

#include iostream

#include complex

#include bitset

#include vector

#include conio.h

#include string

#include fstream

using namespace std;

bool inputData(unsigned long , vectorcomplexdouble ); //手工輸入數(shù)據(jù)

void FFT(unsigned long , vectorcomplexdouble ); //FFT變換

void display(unsigned long , vectorcomplexdouble ); //顯示結(jié)果

bool readDataFromFile(unsigned long , vectorcomplexdouble ); //從文件中讀取數(shù)據(jù)

bool saveResultToFile(unsigned long , vectorcomplexdouble ); //保存結(jié)果至文件中

const double PI = 3.1415926;

int _tmain(int argc, _TCHAR* argv[])

{

vectorcomplexdouble vecList; //有限長(zhǎng)序列

unsigned long ulN = 0; //N

char chChoose = ' '; //功能選擇

//功能循環(huán)

while(chChoose != 'Q' chChoose != 'q')

{

//顯示選擇項(xiàng)

cout "\nPlease chose a function" endl;

cout "\t1.Input data manually, press 'M':" endl;

cout "\t2.Read data from file, press 'F':" endl;

cout "\t3.Quit, press 'Q'" endl;

cout "Please chose:";

//輸入選擇

chChoose = getch();

//判斷

switch(chChoose)

{

case 'm': //手工輸入數(shù)據(jù)

case 'M':

if(inputData(ulN, vecList))

{

FFT(ulN, vecList);

display(ulN, vecList);

saveResultToFile(ulN, vecList);

}

break;

case 'f': //從文檔讀取數(shù)據(jù)

case 'F':

if(readDataFromFile(ulN, vecList))

{

FFT(ulN, vecList);

display(ulN, vecList);

saveResultToFile(ulN, vecList);

}

break;

}

}

return 0;

}

bool Is2Power(unsigned long ul) //判斷是否是2的整數(shù)次冪

{

if(ul 2)

return false;

while( ul 1 )

{

if( ul % 2 )

return false;

ul /= 2;

}

return true;

}

bool inputData(unsigned long ulN, vectorcomplexdouble vecList)

{

//題目

cout "\n\n\n==============================Input Data===============================" endl;

//輸入N

cout "\nInput N:";

cinulN;

if(!Is2Power(ulN)) //驗(yàn)證N的有效性

{

cout "N is invalid (N must like 2, 4, 8, .....), please retry." endl;

return false;

}

//輸入各元素

vecList.clear(); //清空原有序列

complexdouble c;

for(unsigned long i = 0; i ulN; i++)

{

cout "Input x(" i "):";

cin c;

vecList.push_back(c);

}

return true;

}

bool readDataFromFile(unsigned long ulN, vectorcomplexdouble vecList) //從文件中讀取數(shù)據(jù)

{

//題目

cout "\n\n\n===============Read Data From File==============" endl;

//輸入文件名

string strfilename;

cout "Input filename:" ;

cin strfilename;

//打開(kāi)文件

cout "open file " strfilename "......." endl;

ifstream loadfile;

loadfile.open(strfilename.c_str());

if(!loadfile)

{

cout "\tfailed" endl;

return false;

}

else

{

cout "\tsucceed" endl;

}

vecList.clear();

//讀取N

loadfile ulN;

if(!loadfile)

{

cout "can't get N" endl;

return false;

}

else

{

cout "N = " ulN endl;

}

//讀取元素

complexdouble c;

for(unsigned long i = 0; i ulN; i++)

{

loadfile c;

if(!loadfile)

{

cout "can't get enough infomation" endl;

return false;

}

else

cout "x(" i ") = " c endl;

vecList.push_back(c);

}

//關(guān)閉文件

loadfile.close();

return true;

}

bool saveResultToFile(unsigned long ulN, vectorcomplexdouble vecList) //保存結(jié)果至文件中

{

//詢(xún)問(wèn)是否需要將結(jié)果保存至文件

char chChoose = ' ';

cout "Do you want to save the result to file? (y/n):";

chChoose = _getch();

if(chChoose != 'y' chChoose != 'Y')

{

return true;

}

//輸入文件名

string strfilename;

cout "\nInput file name:" ;

cin strfilename;

cout "Save result to file " strfilename "......" endl;

//打開(kāi)文件

ofstream savefile(strfilename.c_str());

if(!savefile)

{

cout "can't open file" endl;

return false;

}

//寫(xiě)入N

savefile ulN endl;

//寫(xiě)入元素

for(vectorcomplexdouble ::iterator i = vecList.begin(); i vecList.end(); i++)

{

savefile *i endl;

}

//寫(xiě)入完畢

cout "save succeed." endl;

//關(guān)閉文件

savefile.close();

return true;

}

void FFT(unsigned long ulN, vectorcomplexdouble vecList)

{

//得到冪數(shù)

unsigned long ulPower = 0; //冪數(shù)

unsigned long ulN1 = ulN - 1;

while(ulN1 0)

{

ulPower++;

ulN1 /= 2;

}

//反序

bitsetsizeof(unsigned long) * 8 bsIndex; //二進(jìn)制容器

unsigned long ulIndex; //反轉(zhuǎn)后的序號(hào)

unsigned long ulK;

for(unsigned long p = 0; p ulN; p++)

{

ulIndex = 0;

ulK = 1;

bsIndex = bitsetsizeof(unsigned long) * 8(p);

for(unsigned long j = 0; j ulPower; j++)

{

ulIndex += bsIndex.test(ulPower - j - 1) ? ulK : 0;

ulK *= 2;

}

if(ulIndex p)

{

complexdouble c = vecList[p];

vecList[p] = vecList[ulIndex];

vecList[ulIndex] = c;

}

}

//計(jì)算旋轉(zhuǎn)因子

vectorcomplexdouble vecW;

for(unsigned long i = 0; i ulN / 2; i++)

{

vecW.push_back(complexdouble(cos(2 * i * PI / ulN) , -1 * sin(2 * i * PI / ulN)));

}

for(unsigned long m = 0; m ulN / 2; m++)

{

cout "\nvW[" m "]=" vecW[m];

}

//計(jì)算FFT

unsigned long ulGroupLength = 1; //段的長(zhǎng)度

unsigned long ulHalfLength = 0; //段長(zhǎng)度的一半

unsigned long ulGroupCount = 0; //段的數(shù)量

complexdouble cw; //WH(x)

complexdouble c1; //G(x) + WH(x)

complexdouble c2; //G(x) - WH(x)

for(unsigned long b = 0; b ulPower; b++)

{

ulHalfLength = ulGroupLength;

ulGroupLength *= 2;

for(unsigned long j = 0; j ulN; j += ulGroupLength)

{

for(unsigned long k = 0; k ulHalfLength; k++)

{

cw = vecW[k * ulN / ulGroupLength] * vecList[j + k + ulHalfLength];

c1 = vecList[j + k] + cw;

c2 = vecList[j + k] - cw;

vecList[j + k] = c1;

vecList[j + k + ulHalfLength] = c2;

}

}

}

}

void display(unsigned long ulN, vectorcomplexdouble vecList)

{

cout "\n\n===========================Display The Result=========================" endl;

for(unsigned long d = 0; d ulN;d++)

{

cout "X(" d ")\t\t\t = " vecList[d] endl;

}

}

下面為STDAFX.H文件:

// stdafx.h : 標(biāo)準(zhǔn)系統(tǒng)包含文件的包含文件,

// 或是常用但不常更改的項(xiàng)目特定的包含文件

#pragma once

#include iostream

#include tchar.h

// TODO: 在此處引用程序要求的附加頭文件

下面為STDAFX.CPP文件:

// stdafx.cpp : 只包括標(biāo)準(zhǔn)包含文件的源文件

// FFT.pch 將成為預(yù)編譯頭

// stdafx.obj 將包含預(yù)編譯類(lèi)型信息

#include "stdafx.h"

// TODO: 在 STDAFX.H 中

//引用任何所需的附加頭文件,而不是在此文件中引用

請(qǐng)給我一份用C語(yǔ)言編輯的用于計(jì)算DFT的程序

#include stdio.h

#include stdlib.h

#include math.h

#include string.h

//#define MyE 2.7182818284590452354

//#define GET_ARRAY_LEN(array,len){len = (sizeof(array) / sizeof(array[0]));}

int main()

{

void fft();

int len,i; //len=N

printf("Input the size of the array: ");//設(shè)定數(shù)組大小

if (scanf("%d",len)==EOF)

return 0;

double arr[len];

printf("Input the arry elements:\n");

for (i=0;ilen;i++)

{

printf("[%d]: (for example: 5Enter)",i);

scanf("%lf",arr[i]);

}

// int len;//自定義長(zhǎng)度

// GET_ARRAY_LEN(a,len);

// printf("%d\n",len);

printf("Result is :\n");

fft(arr,len);

return 0;

}

void fft(double a[],int lang)

{

int N;

int n,k;

N=lang;

double sumsin=0,sumcos=0;

for (k=0;kN;k++)

{

for (n=0;nN;n++)

{

sumcos=sumcos+cos(n*k*8*atan(1)/N)*a[n]; //8*atan(1)=2π

//printf("n=%d,sumcos=%.1lf",n,sumcos);

//printf("\n");

sumsin=sumsin+(-1)*sin(n*k*8*atan(1)/N)*a[n];

//printf("n=%d,sumcos=%.1lf",n,sumsin);

//printf("\n");

}

printf("x[%d]= %.1lf + %.1lfj",k,sumcos,sumsin);

sumcos=0;

sumsin=0;

printf("\n");

}

}

【請(qǐng)尊重我的勞動(dòng)成果,若滿意,請(qǐng)及時(shí)采納~~謝謝!!】

名稱(chēng)欄目:c語(yǔ)言dft函數(shù),df是什么函數(shù)
網(wǎng)站地址:http://chinadenli.net/article47/dsiopej.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)定制開(kāi)發(fā)外貿(mào)網(wǎng)站建設(shè)自適應(yīng)網(wǎng)站網(wǎng)站改版全網(wǎng)營(yíng)銷(xiāo)推廣

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)