国产三级在线看完整版-内射白嫩大屁股在线播放91-欧美精品国产精品综合-国产精品视频网站一区-一二三四在线观看视频韩国-国产不卡国产不卡国产精品不卡-日本岛国一区二区三区四区-成年人免费在线看片网站-熟女少妇一区二区三区四区

儀器網(wǎng)(yiqi.com)歡迎您!

| 注冊(cè)2 登錄
網(wǎng)站首頁(yè)-資訊-話題-產(chǎn)品-評(píng)測(cè)-品牌庫(kù)-供應(yīng)商-展會(huì)-招標(biāo)-采購(gòu)-知識(shí)-技術(shù)-社區(qū)-資料-方案-產(chǎn)品庫(kù)-視頻

問(wèn)答社區(qū)

c語(yǔ)言濾波器

V三分熱 2016-03-29 11:49:01 834  瀏覽
  • 很簡(jiǎn)單的濾波器 就是matlab里的 1/(s+1) 不知道怎么寫(xiě) 我用的 參數(shù)是 10 1 也就是 1/(10s+1) 請(qǐng)大家?guī)兔?xiě)個(gè)C程序 不勝感激

參與評(píng)論

全部評(píng)論(1條)

  • 我昱云南的人民 2016-03-30 03:47:15
    這個(gè)可比你想象的復(fù)雜多了,s是個(gè)復(fù)變量,1/(s+1)極點(diǎn)在-1,要想用C語(yǔ)言寫(xiě),必須理解清楚下面幾個(gè)問(wèn)題: 1、輸入必須是個(gè)有限序列,比如(x+yi),x和y分別是兩個(gè)長(zhǎng)度為N的數(shù)組 2、要過(guò)濾的頻率,必須是個(gè)整型值,或者是個(gè)整型區(qū)間 3、輸出結(jié)果同樣是兩個(gè)長(zhǎng)度為N的數(shù)組(p+qi) 4、整個(gè)程序需要使用Z基本的復(fù)數(shù)運(yùn)算,這一點(diǎn)C語(yǔ)言本身不提供,必須手工寫(xiě)復(fù)函數(shù)運(yùn)算庫(kù) 5、實(shí)現(xiàn)的時(shí)候具體算法還需要編,這里才是你問(wèn)題的核心。 我可以送你一段FFT的程序,自己琢磨吧,和MATLAB的概念差別很大: #include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> #include "complex.h" extern "C" { // Discrete Fourier Transform (Basic Version, Without Any Enhancement) // return - Without Special Meaning, constantly, zero int DFT (long count, CComplex * input, CComplex * output) { assert(count); assert(input); assert(output); CComplex F, X, T, W; int n, i; long N = abs(count); long Inversing = count < 0? 1: -1; for(n = 0; n < N ; n++){ // compute from line 0 to N-1 F = CComplex(0.0f, 0.0f); // clear a line for(i = 0; i < N; i++) { T = input[i]; W = HarmonicPI2(Inversing * n * i, N); X = T * W; F += X; // fininshing a line }//next i // save data to outpus memcpy(output + n, &F, sizeof(F)); }//next n return 0; }//end DFT int fft (long count, CComplex * input, CComplex * output) { assert(count); assert(input); assert(output); int N = abs(count); long Inversing = count < 0? -1: 1; if (N % 2 || N < 5) return DFT(count, input, output); long N2 = N / 2; CComplex * iEven = new CComplex[N2]; memset(iEven, 0, sizeof(CComplex) * N2); CComplex * oEven = new CComplex[N2]; memset(oEven, 0, sizeof(CComplex) * N2); CComplex * iOdd = new CComplex[N2]; memset(iOdd , 0, sizeof(CComplex) * N2); CComplex * oOdd = new CComplex[N2]; memset(oOdd , 0, sizeof(CComplex) * N2); int i = 0; CComplex W; for(i = 0; i < N2; i++) { iEven[i] = input[i * 2]; iOdd [i] = input[i * 2 + 1]; }//next i fft(N2 * Inversing, iEven, oEven); fft(N2 * Inversing, iOdd, oOdd ); for(i = 0; i < N2; i++) { W = HarmonicPI2(Inversing * (- i), N); output[i] = oEven[i] + W * oOdd[i]; output[i + N2] = oEven[i] - W * oOdd[i]; }//next i return 0; }//end FFT void __stdcall FFT( long N, // Serial Length, N > 0 for DFT, N < 0 for iDFT - inversed Discrete Fourier Transform double * inputReal, double * inputImaginary, // inputs double * AmplitudeFrequences, double * PhaseFrequences) // outputs { if (N == 0) return; if (!inputReal && !inputImaginary) return; short n = abs(N); CComplex * input = new CComplex[n]; memset(input, 0, sizeof(CComplex) * n); CComplex * output= new CComplex[n]; memset(output,0, sizeof(CComplex) * n); double rl = 0.0f, im = 0.0f; int i = 0; for (i = 0; i < n; i++) { rl = 0.0f; im = 0.0f; if (inputReal) rl = inputReal[i]; if (inputImaginary) im = inputImaginary[i]; input[i] = CComplex(rl, im); }//next i int f = fft(N, input, output); double factor = n; //factor = sqrt(factor); if (N > 0) factor = 1.0f; else factor = 1.0f / factor; //end if for (i = 0; i < n; i++) { if (AmplitudeFrequences) AmplitudeFrequences[i] = output[i].getReal() * factor; if (PhaseFrequences) PhaseFrequences[i] = output[i].getImaginary() * factor; }//next i delete [] output; delete [] input; return ; }//end FFT int __cdecl main(int argc, char * argv[]) { fprintf(stderr, "%s usage:\n", argv[0]); fprintf(stderr, "Public Declare Sub FFT Lib \"wfft.exe\" \ (ByVal N As Long, ByRef inputReal As Double, ByRef inputImaginary As Double, \ ByRef freqAmplitude As Double, ByRef freqPhase As Double)"); return 0; }//end main };//end extern "C"

    贊(15)

    回復(fù)(0)

    評(píng)論

熱門(mén)問(wèn)答

c語(yǔ)言濾波器
很簡(jiǎn)單的濾波器 就是matlab里的 1/(s+1) 不知道怎么寫(xiě) 我用的 參數(shù)是 10 1 也就是 1/(10s+1) 請(qǐng)大家?guī)兔?xiě)個(gè)C程序 不勝感激
2016-03-29 11:49:01 834 1
C語(yǔ)言,計(jì)時(shí)器
給段C語(yǔ)言編寫(xiě)的計(jì)時(shí)器代碼,謝謝
2017-10-08 06:42:46 735 1
VHDL語(yǔ)言設(shè)計(jì)濾波器
設(shè)計(jì)FIR低通濾波器,系統(tǒng)頻率為50MHz,通帶截止頻率Fpass為1MHz,阻帶截止頻率Fstop為4MHz,通帶Z大衰減Apass為1dB,阻帶Z小衰減Astop為30dB。 程序和必要的程序注釋 謝謝
2011-06-19 05:59:16 288 1
R/C 濾波器,什么是R/C 濾波器
 
2018-01-10 03:49:31 525 3
c語(yǔ)言IPC連接
傳三個(gè)參數(shù),IP,用戶(hù),密碼,連接成功返回TURE,否則返回FALSE
2014-10-29 22:13:23 313 1
c語(yǔ)言編程軟件 for mac
有哪些軟件。給些地址吧、軟件要付錢(qián)么?! 麻煩表復(fù)制別人的,謝了
2016-02-02 10:11:45 446 2
c語(yǔ)言編程軟件有哪些??
 
2018-11-12 11:03:20 326 0
C語(yǔ)言編程軟件名字叫什么
 
2013-08-08 13:32:15 548 6
c語(yǔ)言編程軟件哪個(gè)好用
 
2016-11-21 15:07:32 289 2
c語(yǔ)言編程軟件怎么安裝
 
2017-02-03 20:59:52 375 3
c語(yǔ)言用什么編程軟件?
 
2018-11-17 02:18:53 288 0
機(jī)器人對(duì)話c語(yǔ)言編程
模擬機(jī)器人與你的對(duì)話 機(jī)器人:你所學(xué)專(zhuān)業(yè)? 人:計(jì)算機(jī) 機(jī)器人:姓名? 人:張三 系統(tǒng)建立一個(gè)文件,文件內(nèi)容:計(jì)算機(jī)--張三 機(jī)器人:你所學(xué)專(zhuān)業(yè)? 人:YL 機(jī)器人:姓名? 人:李四 系統(tǒng)建立一個(gè)文件,文件內(nèi)容:YL--李四
2018-11-28 02:02:59 476 0
c語(yǔ)言寫(xiě)的計(jì)時(shí)器
 
2016-09-10 21:55:59 464 1
手機(jī)上有c語(yǔ)言編程軟件嗎?
 
2015-07-30 17:17:21 344 3
手機(jī)上有c語(yǔ)言編程軟件嗎?
 
2017-11-26 08:43:13 459 1
求C語(yǔ)言計(jì)時(shí)器的例子
我想為執(zhí)行某個(gè)功能建立一個(gè)計(jì)時(shí)器。比如說(shuō),當(dāng)A功能開(kāi)始時(shí),A計(jì)時(shí)器開(kāi)始計(jì)時(shí),當(dāng)A功能結(jié)束時(shí),A計(jì)時(shí)器結(jié)束計(jì)時(shí),將A執(zhí)行的時(shí)間返回給我,這樣的計(jì)時(shí)器該怎么寫(xiě)?
2011-11-29 00:21:26 642 2
c語(yǔ)言器 的編程代碼
 
2013-07-14 15:52:34 326 3
c語(yǔ)言gsensor急加速算法
 
2018-11-13 07:05:55 407 0
c語(yǔ)言 程序設(shè)計(jì) 關(guān)于程序調(diào)試
#include"stdio.h"#include"stdlib.h"#include"time.h"voidmain(){inti,j;statics0,s1;time_tt;srand((unsigned)time(&t));for(i=0;i<1000;i++){j=rand()%2;if(j==1)s0++;else;s1++;}... #include"stdio.h" #include"stdlib.h" #include"time.h" void main() { int i,j; static s0,s1; time_t t; srand((unsigned) time(&t)); for(i=0;i<1000;i++) { j=rand()%2; if(j==1) s0++; else; s1++; } printf("\n s0=%d s1=%d \n ",s0,s1); } 為什么這段程序 不管是在單步調(diào)試 還是斷點(diǎn)調(diào)試 都看不到 s0 和s1 的值呢? 只能看到其他的 i j Loaded 'ntdll.dll', no matching symbolic information found. 這又是什么意思?。? 展開(kāi)
2011-05-25 02:19:45 449 3

4月突出貢獻(xiàn)榜

推薦主頁(yè)

最新話題