精华内容
下载资源
问答
  • 傅里叶算法的使用
    千次阅读
    2020-12-31 08:42:13

    分步傅里叶算法的MATLAB程序实现

    分步傅里叶算法的MATLAB程序实现举例

    模型:

    其中:

    线性部分:

    两边同时对x变量作傅里叶变换

    两边积分

    最后有

    再对x变量作作傅里叶逆变换

    非线性部分:

    两边积分

    当时

    最后有

    折射率部分:

    两边同时对x变量作傅里叶变换

    再对x变量作作傅里叶逆变换

    MATLAB程序实现:

    clear all

    delta=1;

    x0=1;

    %%-------------------

    n=2048;

    hx=0.06;

    x=(-n/2:n/2-1)*hx;

    hw=2*pi/(n*hx);

    w=fftshift((-n/2:n/2-1)*hw);

    %%-------------------

    q=exp(-1*(x-x0).^2/2)+ exp(-1*(x+x0).^2/2);

    % q=sech(x);

    u1(:,1)=(abs(q).^2)';

    %-------------------

    L=500;

    nm=L*100;

    h=L/nm;

    %-------------------

    for j=1:nm

    j;

    Dz=exp(delta*j*h)

    D=exp(i*((i*w).^2/2)*h/2);

    qstep1=ifft(D.*fft(q));

    n_index=ifft(fft(abs(qstep1).^2)./(Dz*w.^2+1));

    N=exp(i*n_index*h);

    qstep2=N.*qstep1;

    q=ifft(D.*fft(qstep2));

    u=abs(q);

    r=floor(2+(j-1)/L);

    u1(:,r)=u';

    end

    z=0:L*h:L;

    figure(1)

    mesh(x,z,u1');

    view(0,90)

    figure(2)

    plot(x,u1(:,end),'r',x,V,'b')

    虚时间变换:

    作虚时间变换:

    得到

    MATLAB程序实现:

    线性部分:

    两边同时傅里叶变换

    两边积分

    最后有

    再作傅里叶逆变换

    非线性部分:

    两边积分

    当时

    最后有

    clear all

    Lh=0;

    p=1;

    omega=1;

    Dz=0;

    %%-------------------

    n=2048;

    hx=0.06;

    x=(-n/2:n/2-1)*hx;

    hw=2*pi/(n*hx);

    w=fftshift((-n/2:n/2-1)*hw);

    %%-------------------

    q=exp(-1*(x).^2/2);

    % q=sech(x);

    intensity=2;

    u1(:,1)=(abs(q).^2)';

    %-------------------

    V=p*(cos(omega*x)).^2.*(1+Lh*exp(-x.^8/128));

    %--------------------

    L=500;

    nm=L*100;

    h=L/nm;

    %-------------------

    for j=1:nm

    j;

    D=exp(((i*w).^2/2)*h/2);

    qstep1=ifft(D.*fft(q));

    n_index=ifft(fft(abs(qstep1).^2)./(Dz*w.^2+1));

    N=exp((V+n_index)*h);

    qstep2=N.*qstep1;

    q=ifft(D.*fft(qstep2));

    q=sqrt(intensity)*q/sqrt(sum(abs(q).^2)*hx);

    u=abs(q);

    r=floor(2+(j-1)/L);

    u1(:,r)=u';

    end

    kin=-sum((q(3:end)-q(1:end-2)).^2)/4/hx;

    p_i=sum(2*q.^2.*(abs(q).^2+V+n_index))*hx;

    b=(kin+p_i)/2/intensity

    z=0:L*h:L;

    figure(1)

    mesh(x,z,u1');

    view(0,90)

    figure(2)

    plot(x,u1(:,end),'r',x,V,'b')

    更多相关内容
  • 算法实现: 线性部分: 两边同时傅里叶变换 两边积分 即 最后有 再作傅里叶逆变换 非线性部分: 两边积分 当h->0时 最后有 程序源码如下: 虚时间变换 做虚时间变换 则有: 即 再将记为,有......

    分步傅里叶算法的MATLAB程序实现


    1、原文下载:

    本算法原文如下,有需要的朋友可以点击进行下载

    序号 原文(点击下载)
    本项目原文 【老生谈算法】分步傅里叶算法的MATLAB程序实现.doc

    2、算法详解:

    一、模型:

    在这里插入图片描述

    其中:
    在这里插入图片描述


    在这里插入图片描述

    线性部分:

    展开全文
  • 为提高模拟超连续谱(SC)产生的精度, 在不增加计算量的情况下对传统分步傅里叶算法作了一定的改进。传统分步傅里叶算法只考虑初始脉冲中心频率对应的色散系数, 而超连续谱的光谱范围很大, 当色散系数随波长变化较大时...
  • 快速傅里叶变化讲解 实验:编制快速傅里叶算法
  • 文件是一个使用C语言实现的快速傅立叶算法,C语言编程,在DSP环境下实现的,适合初学者的,可用与DSP等信号处理领域。
  • 本例程是利用STM32F429实现了FFT算法,调试成功,可以直接使用,大家可以根据实例修改不同的算法模式,实现不同功能,本例程已经应用到产品上,有需要的可以下载,共同交流学习。
  • 给出一种用MATLAB实现信号频谱分析和显示的快速傅里叶算法的方法...
  • 全周波傅里叶算法

    2021-05-25 02:14:22
    全周波傅里叶算法根据傅里叶级数,我们将待分析的周期函数电流信号i(t)表示为()tn sin I t n cos I I t i 11n ns 11n nc 0ω+ω+=∑∑∞=∞=可用和分别乘式(8-46)两边,然后在t 0到t 0+T 积分,得到 dt t n cos )t ...

    全周波傅里叶算法

    根据傅里叶级数,我们将待分析的周期函数电流信号i(t)表示为

    ()t

    n sin I t n cos I I t i 11n ns 11n nc 0ω+ω+=∑∑∞=∞=

    可用和分别乘式(8-46)两边,然后在t 0到t 0+T 积分,得到 dt t n cos )t (i T 2I T t t 1nc

    00?+ω= (8—47) dt t n t i T I T t t ns ?+=001sin )(2ω (8—48)

    每工频周期T 采样N 次,对式(8-47)和式(8-48)用梯形法数值积分来代替,则得

    N n k i N I N k k nc

    π2cos 21∑== (8—49) N n k

    i N I N

    k k ns π2sin 21∑== (8—50) 式中k 、i k ——第k 采样及第k 个采样值

    电流n 次谐波幅值(最大值)和相位(余弦函数的初相)分别为

    22nc ns nm I I I += (8—51)

    46f428835dd2b595f2db9d2b45630206.png

    (8—52)

    写成复数形式有

    ns nc n jI I I +=

    对于基波分量,若每周采样12点(N =12),则式(8-49)和式(8-50)可简化为

    12610842117511)(21)(236i i i i i i i i i i I c +-+--++--= (8—53) )(23)(21)(61084211751931i i i i i i i i i i I s --++--++-= (8—54)

    在微机保护的实际编程中,为尽量避免采用费时的乘法指令,在准确度容许的情况下,为了获得对采样结果分析计算的快速性,可用(1—1/8)近似代替上两式中的2/3,而后1/2和1/8采用较省时的移位指令来实现。

    全周波傅里叶算法本身具有滤波作用,在计算基频分量时,能抑制恒定直流和消除各整数次谐波,但对衰减的直流分量将造成基频(或其它倍频)分量计算结果的误差。另外用近似数值计算代替积也会导致一定的误差。算法的数据窗为一个工频周期,属于长数据窗类型,响应时间较长。

    展开全文
  • 快速傅里叶变换算法与应用,电子书,好不容易找到,希望对你的学习工作有帮助,如果觉得不错,请支持正版。
  • 简易的能实现FFT快速傅里叶算法,MATLAB编译环境,适用于教学例题
  • So the problem we need to solve is that of multiplying polynomials fast. Doing it the regular convolution way takes quadratic time -O(n2). This is OK for small n but won't do for large n. ...
  • FFT是离散傅里叶变换的快速算法,也可用于计算离散傅里叶变换的逆变换。快速傅里叶变换有广泛的应用,如数字信号处理、计算大整数乘法、求解偏微分方程等等
  • 【老生谈算法】分步傅里叶算法的MATLAB程序实现.doc
  • 快速傅立叶算法,采用时域抽取法FFT(Decimation-In-Time FFT, 简称 DIT - FFT),完全采用标准C++语言编写,算法上采用了蝶形运算原理,数据结构采用 STL 模板库存储动态数组,采用 complex 类处理复数运算。...
  • 快速傅里叶算法程序

    2015-03-20 10:29:07
    通过编程实现蝶形快速傅里叶算法void fft ; 快速傅里叶变换 void initW ; 初始化旋转因子 void change ; 变址 复数运算 void add complex complex complex ; void mul complex complex complex ; void sub ...
  • 用c语言实现的快速傅里叶算法,用了三个大循环,时域乱序输入频域自然序输出
  • 傅里叶算法的采样电流计算.doc
  • 使用matlab实现的快速傅立叶变换(FFT)算法实验
  • 快速傅里叶算法(FFT)c51实现 直接使用 快速傅里叶算法(FFT)c51实现 直接使用
  • 分布傅里叶算法_源码

    2021-09-29 00:15:38
    split_step_fourier_method_split_split-stepfourier_opticalfiber_分布傅里叶_分布傅里叶算法_源码.rar
  • 离散傅里叶变换及其快速算法
  • 周期信号 全波 傅里叶算法 微机继电保护 电力系统
  • 快速傅里叶分析算法快速傅里叶分析算法.pdf
  • 利用MATLAB工具对改进傅里叶算法和传统傅里叶算法的计算结果进行仿真,由仿真结果可知,在不考虑非整次谐波分量影响时,改进傅里叶算法对滤除电流、电压故障信号中的衰减直流分量的效果十分理想。在此基础上,通过...
  • 傅里叶变换算法

    千次阅读 2022-05-04 08:40:55
       傅里叶变换的核心在于,“任何连续周期信号可以由一组适当的正弦曲线组合而成”,在这个基础上对信号的中特定频率的正弦波进行分解或者重组,基于频率方面分析波形。 一、傅里叶变换的意义    近似周期性的方...

       傅里叶变换的核心在于,“任何连续周期信号可以由一组适当的正弦曲线组合而成”,在这个基础上对信号的中特定频率的正弦波进行分解或者重组,基于频率方面分析波形。

    一、傅里叶变换的意义

       近似周期性的方波(橙色),可采用6组正弦波(蓝色)合成,这是傅里叶的基础。
    在这里插入图片描述
       对数字信号处理或者工程数学有一定基础,就明白傅里叶变换的价值。一般情况下的信号或者波形随时间变化,称为时域信号,时域(Time domain)是描述数学函数或物理信号对时间的关系。而以频率和幅度表示信号称为频域,频域(frequency domain)是描述信号在频率方面特性时用到的一种坐标系。其数学理论上暂且不理,针对嵌入式系统开发,只探讨其物理意义或者应用场景。
       对数字信号处理或者工程数学有一定基础,就明白傅里叶变换的价值。一般情况下的信号或者波形随时间变化,称为时域信号,时域(Time domain)是描述数学函数或物理信号对时间的关系。而以频率和幅度表示信号称为频域,频域(frequency domain)是描述信号在频率方面特性时用到的一种坐标系。其数学理论上暂且不理,针对嵌入式系统开发,只探讨其物理意义或者应用场景。
    在这里插入图片描述
       傅里叶变换是一种信号分析方法,让我们对信号的构成和特点进行深入的、定量的研究。把信号通过频谱的方式进行准确的、定量的描述。将原来难以处理的时域信号转换成了易于分析的频域信号,即傅里叶变换的核心是从时域到频域的变换。

    二、变换方式

       数字信号属于离散值,对应的称为离散傅里叶变换(DFT),是傅里叶变换在时域和频域上都呈现离散的形式,将时域信号的采样变换为在离散时间傅里叶变换(DTFT)频域的采样。在形式上,变换两端(时域和频域上)的序列是有限长的,而实际上这两组序列都应当被认为是离散周期信号的主值序列。即使对有限长的离散信号作DFT,也应当将其看作经过周期延拓成为周期信号再作变换。
       在实际应用中通常采用快速傅里叶变换以高效计算效率,快速傅里叶变换 FFT(Fast Fourier Transformation)是离散傅里叶变换 DFT(Discrete Fourier Transform)的快速算法。采用这种算法能使计算机计算离散傅里叶变换所需要的乘法次数大为减少,特别是被变换的抽样点数N越多,FFT算法计算量的节省就越显著。同理,从频域到时域的变换,称为逆变换,快速傅里叶逆变换 IFFT和离散傅里叶逆变换IDFT。

    三、应用

       一般嵌入式系统使用快速傅里叶变换是分析某段信号中混合的杂波干扰,或者剔除某个频段后再逆变换。有些高端示波器可以对信号快速傅里叶变换 FFT,直接显示高频杂波的频率或者较大幅度干扰源的频率,以便由针对性的检查电路窜扰。

    四、代码

       使用c语言的FFT/IFFT进行处理

    include <math.h>
    #include <stdio.h>
    #include "string.h"
    
    typedef struct
    {
        float real;
        float imag;
    } complex_t;
    
    #ifndef PI
    #define PI             (3.14159265)
    #endif
    
    #define TYPE_FFT_E     float    /* Type is the same with complex_t member */
    
    typedef complex_t TYPE_FFT;  /* Define complex_t in Config.h */
    typedef unsigned int                      uint32_t;
    
    #define     SAMPLE_NODES    (1024)
    complex_t   fft_buff[SAMPLE_NODES];
    
    //python生成的3个sin混合的波形数组
    float my_sin_wave_table[] =
    {
        0.000000,13.308217,25.359460,35.142296,42.082633,46.140080,47.788611,47.887148,47.470293,47.507139,48.682920,51.252751,\
        55.000000,59.307883,63.326941,66.199152,67.286436,66.350198,63.639610,59.866963,56.074110,53.418823,52.928233,55.274323,\
        60.621778,68.582540,78.287693,88.561119,98.156743,106.007043,111.428222,114.237346,114.756729,113.706291,112.009861,\
        110.560634,110.000000,110.560634,112.009861,113.706291,114.756729,114.237346,111.428222,106.007043,98.156743,88.561119,\
        78.287693,68.582540,60.621778,55.274323,52.928233,53.418823,56.074110,59.866963,63.639610,66.350198,67.286436,66.199152,\
        63.326941,59.307883,55.000000,51.252751,48.682920,47.507139,47.470293,47.887148,47.788611,46.140080,42.082633,35.142296,\
        25.359460,13.308217,0.000000,-13.308217,-25.359460,-35.142296,-42.082633,-46.140080,-47.788611,-47.887148,-47.470293,\
        -47.507139,-48.682920,-51.252751,-55.000000,-59.307883,-63.326941,-66.199152,-67.286436,-66.350198,-63.639610,-59.866963,\
        -56.074110,-53.418823,-52.928233,-55.274323,-60.621778,-68.582540,-78.287693,-88.561119,-98.156743,-106.007043,-111.428222,\
        -114.237346,-114.756729,-113.706291,-112.009861,-110.560634,-110.000000,-110.560634,-112.009861,-113.706291,-114.756729,\
        -114.237346,-111.428222,-106.007043,-98.156743,-88.561119,-78.287693,-68.582540,-60.621778,-55.274323,-52.928233,\
        -53.418823,-56.074110,-59.866963,-63.639610,-66.350198,-67.286436,-66.199152,-63.326941,-59.307883,-55.000000,\
        -51.252751,-48.682920,-47.507139,-47.470293,-47.887148,-47.788611,-46.140080,-42.082633,-35.142296,-25.359460,\
        -13.308217,-0.000000,13.308217,25.359460,35.142296,42.082633,46.140080,47.788611,47.887148,47.470293,47.507139,\
        48.682920,51.252751,55.000000,59.307883,63.326941,66.199152,67.286436,66.350198,63.639610,59.866963,56.074110,\
        53.418823,52.928233,55.274323,60.621778,68.582540,78.287693,88.561119,98.156743,106.007043,111.428222,114.237346,\
        114.756729,113.706291,112.009861,110.560634,110.000000,110.560634,112.009861,113.706291,114.756729,114.237346,\
        111.428222,106.007043,98.156743,88.561119,78.287693,68.582540,60.621778,55.274323,52.928233,53.418823,56.074110,\
        59.866963,63.639610,66.350198,67.286436,66.199152,63.326941,59.307883,55.000000,51.252751,48.682920,47.507139,\
        47.470293,47.887148,47.788611,46.140080,42.082633,35.142296,25.359460,13.308217,0.000000,-13.308217,-25.359460,\
        -35.142296,-42.082633,-46.140080,-47.788611,-47.887148,-47.470293,-47.507139,-48.682920,-51.252751,-55.000000,\
        -59.307883,-63.326941,-66.199152,-67.286436,-66.350198,-63.639610,-59.866963,-56.074110,-53.418823,-52.928233,\
        -55.274323,-60.621778,-68.582540,-78.287693,-88.561119,-98.156743,-106.007043,-111.428222,-114.237346,-114.756729,\
        -113.706291,-112.009861,-110.560634,-110.000000,-110.560634,-112.009861,-113.706291,-114.756729,-114.237346,-111.428222,\
        -106.007043,-98.156743,-88.561119,-78.287693,-68.582540,-60.621778,-55.274323,-52.928233,-53.418823,-56.074110,-59.866963,\
        -63.639610,-66.350198,-67.286436,-66.199152,-63.326941,-59.307883,-55.000000,-51.252751,-48.682920,-47.507139,-47.470293,\
        -47.887148,-47.788611,-46.140080,-42.082633,-35.142296,-25.359460,-13.308217,-0.000000,13.308217,25.359460,35.142296,\
        42.082633,46.140080,47.788611,47.887148,47.470293,47.507139,48.682920,51.252751,55.000000,59.307883,63.326941,66.199152,\
        67.286436,66.350198,63.639610,59.866963,56.074110,53.418823,52.928233,55.274323,60.621778,68.582540,78.287693,88.561119,\
        98.156743,106.007043,111.428222,114.237346,114.756729,113.706291,112.009861,110.560634,110.000000,110.560634,112.009861,\
        113.706291,114.756729,114.237346,111.428222,106.007043,98.156743,88.561119,78.287693,68.582540,60.621778,55.274323,\
        52.928233,53.418823,56.074110,59.866963,63.639610,66.350198,67.286436,66.199152,63.326941,59.307883,55.000000,51.252751,\
        48.682920,47.507139,47.470293,47.887148,47.788611,46.140080,42.082633,35.142296,25.359460,13.308217,0.000000,-13.308217,\
        -25.359460,-35.142296,-42.082633,-46.140080,-47.788611,-47.887148,-47.470293,-47.507139,-48.682920,-51.252751,-55.000000,\
        -59.307883,-63.326941,-66.199152,-67.286436,-66.350198,-63.639610,-59.866963,-56.074110,-53.418823,-52.928233,-55.274323,\
        -60.621778,-68.582540,-78.287693,-88.561119,-98.156743,-106.007043,-111.428222,-114.237346,-114.756729,-113.706291,\
        -112.009861,-110.560634,-110.000000,-110.560634,-112.009861,-113.706291,-114.756729,-114.237346,-111.428222,-106.007043,\
        -98.156743,-88.561119,-78.287693,-68.582540,-60.621778,-55.274323,-52.928233,-53.418823,-56.074110,-59.866963,-63.639610,\
        -66.350198,-67.286436,-66.199152,-63.326941,-59.307883,-55.000000,-51.252751,-48.682920,-47.507139,-47.470293,-47.887148,\
        -47.788611,-46.140080,-42.082633,-35.142296,-25.359460,-13.308217,-0.000000,13.308217,25.359460,35.142296,42.082633,\
        46.140080,47.788611,47.887148,47.470293,47.507139,48.682920,51.252751,55.000000,59.307883,63.326941,66.199152,67.286436,\
        66.350198,63.639610,59.866963,56.074110,53.418823,52.928233,55.274323,60.621778,68.582540,78.287693,88.561119,98.156743,\
        106.007043,111.428222,114.237346,114.756729,113.706291,112.009861,110.560634,110.000000,110.560634,112.009861,113.706291,\
        114.756729,114.237346,111.428222,106.007043,98.156743,88.561119,78.287693,68.582540,60.621778,55.274323,52.928233,53.418823,\
        56.074110,59.866963,63.639610,66.350198,67.286436,66.199152,63.326941,59.307883,55.000000,51.252751,48.682920,47.507139,\
        47.470293,47.887148,47.788611,46.140080,42.082633,35.142296,25.359460,13.308217,0.000000,-13.308217,-25.359460,-35.142296,\
        -42.082633,-46.140080,-47.788611,-47.887148,-47.470293,-47.507139,-48.682920,-51.252751,-55.000000,-59.307883,-63.326941,\
        -66.199152,-67.286436,-66.350198,-63.639610,-59.866963,-56.074110,-53.418823,-52.928233,-55.274323,-60.621778,-68.582540,\
        -78.287693,-88.561119,-98.156743,-106.007043,-111.428222,-114.237346,-114.756729,-113.706291,-112.009861,-110.560634,\
        -110.000000,-110.560634,-112.009861,-113.706291,-114.756729,-114.237346,-111.428222,-106.007043,-98.156743,-88.561119,\
        -78.287693,-68.582540,-60.621778,-55.274323,-52.928233,-53.418823,-56.074110,-59.866963,-63.639610,-66.350198,-67.286436,\
        -66.199152,-63.326941,-59.307883,-55.000000,-51.252751,-48.682920,-47.507139,-47.470293,-47.887148,-47.788611,-46.140080,\
        -42.082633,-35.142296,-25.359460,-13.308217,-0.000000,13.308217,25.359460,35.142296,42.082633,46.140080,47.788611,47.887148,\
        47.470293,47.507139,48.682920,51.252751,55.000000,59.307883,63.326941,66.199152,67.286436,66.350198,63.639610,59.866963,\
        56.074110,53.418823,52.928233,55.274323,60.621778,68.582540,78.287693,88.561119,98.156743,106.007043,111.428222,114.237346,\
        114.756729,113.706291,112.009861,110.560634,110.000000,110.560634,112.009861,113.706291,114.756729,114.237346,111.428222,\
        106.007043,98.156743,88.561119,78.287693,68.582540,60.621778,55.274323,52.928233,53.418823,56.074110,59.866963,63.639610,\
        66.350198,67.286436,66.199152,63.326941,59.307883,55.000000,51.252751,48.682920,47.507139,47.470293,47.887148,47.788611,\
        46.140080,42.082633,35.142296,25.359460,13.308217,0.000000,-13.308217,-25.359460,-35.142296,-42.082633,-46.140080,-47.788611,\
        -47.887148,-47.470293,-47.507139,-48.682920,-51.252751,-55.000000,-59.307883,-63.326941,-66.199152,-67.286436,-66.350198,\
        -63.639610,-59.866963,-56.074110,-53.418823,-52.928233,-55.274323,-60.621778,-68.582540,-78.287693,-88.561119,-98.156743,\
        -106.007043,-111.428222,-114.237346,-114.756729,-113.706291,-112.009861,-110.560634,-110.000000,-110.560634,-112.009861,\
        -113.706291,-114.756729,-114.237346,-111.428222,-106.007043,-98.156743,-88.561119,-78.287693,-68.582540,-60.621778,-55.274323,\
        -52.928233,-53.418823,-56.074110,-59.866963,-63.639610,-66.350198,-67.286436,-66.199152,-63.326941,-59.307883,-55.000000,\
        -51.252751,-48.682920,-47.507139,-47.470293,-47.887148,-47.788611,-46.140080,-42.082633,-35.142296,-25.359460,-13.308217,\
        -0.000000,13.308217,25.359460,35.142296,42.082633,46.140080,47.788611,47.887148,47.470293,47.507139,48.682920,51.252751,\
        55.000000,59.307883,63.326941,66.199152,67.286436,66.350198,63.639610,59.866963,56.074110,53.418823,52.928233,55.274323,\
        60.621778,68.582540,78.287693,88.561119,98.156743,106.007043,111.428222,114.237346,114.756729,113.706291,112.009861,\
        110.560634,110.000000,110.560634,112.009861,113.706291,114.756729,114.237346,111.428222,106.007043,98.156743,88.561119,\
        78.287693,68.582540,60.621778,55.274323,52.928233,53.418823,56.074110,59.866963,63.639610,66.350198,67.286436,66.199152,\
        63.326941,59.307883,55.000000,51.252751,48.682920,47.507139,47.470293,47.887148,47.788611,46.140080,42.082633,35.142296,\
        25.359460,13.308217,0.000000,-13.308217,-25.359460,-35.142296,-42.082633,-46.140080,-47.788611,-47.887148,-47.470293,\
        -47.507139,-48.682920,-51.252751,-55.000000,-59.307883,-63.326941,-66.199152,-67.286436,-66.350198,-63.639610,-59.866963,\
        -56.074110,-53.418823,-52.928233,-55.274323,-60.621778,-68.582540,-78.287693,-88.561119,-98.156743,-106.007043,-111.428222,\
        -114.237346,-114.756729,-113.706291,-112.009861,-110.560634,-110.000000,-110.560634,-112.009861,-113.706291,-114.756729,\
        -114.237346,-111.428222,-106.007043,-98.156743,-88.561119,-78.287693,-68.582540,-60.621778,-55.274323,-52.928233,-53.418823,\
        -56.074110,-59.866963,-63.639610,-66.350198,-67.286436,-66.199152,-63.326941,-59.307883,-55.000000,-51.252751,-48.682920,\
        -47.507139,-47.470293,-47.887148,-47.788611,-46.140080,-42.082633,-35.142296,-25.359460,-13.308217,-0.000000,13.308217,\
        25.359460,35.142296,42.082633,46.140080,47.788611,47.887148,47.470293,47.507139,48.682920,51.252751,55.000000,59.307883,\
        63.326941,66.199152,67.286436,66.350198,63.639610,59.866963,56.074110,53.418823,52.928233,55.274323,60.621778,68.582540,\
        78.287693,88.561119,98.156743,106.007043,111.428222,114.237346,114.756729,113.706291,112.009861,110.560634,110.000000,\
        110.560634,112.009861,113.706291,114.756729,114.237346,111.428222,106.007043,98.156743,88.561119,78.287693,68.582540,\
        60.621778,55.274323,52.928233,53.418823,56.074110,59.866963,63.639610,66.350198,67.286436,66.199152,63.326941,59.307883,\
        55.000000,51.252751,48.682920,47.507139,47.470293,47.887148,47.788611,46.140080,42.082633,35.142296,25.359460,13.308217,\
        0.000000,-13.308217,-25.359460,-35.142296,-42.082633,-46.140080,-47.788611,-47.887148,-47.470293,-47.507139,-48.682920,\
        -51.252751,-55.000000,-59.307883,-63.326941,-66.199152,-67.286436,-66.350198,-63.639610,-59.866963,-56.074110,-53.418823,\
        -52.928233,-55.274323,-60.621778,-68.582540,-78.287693,-88.561119,-98.156743,-106.007043,-111.428222,-114.237346,-114.756729,\
        -113.706291,-112.009861,-110.560634,-110.000000,-110.560634,-112.009861,-113.706291,-114.756729,-114.237346,-111.428222,\
        -106.007043,-98.156743,-88.561119,-78.287693,-68.582540,-60.621778,-55.274323,-52.928233,-53.418823,-56.074110,-59.866963,\
        -63.639610,-66.350198,-67.286436,-66.199152,-63.326941,-59.307883,-55.000000,-51.252751,-48.682920,-47.507139,-47.470293,\
        -47.887148,-47.788611,-46.140080,-42.082633,-35.142296,-25.359460,-13.308217,-0.000000,13.308217,25.359460,35.142296,\
        42.082633,46.140080,47.788611,47.887148,47.470293,47.507139,48.682920,51.252751,55.000000,59.307883,63.326941,66.199152,\
        67.286436,66.350198,63.639610,59.866963,56.074110,53.418823,52.928233,55.274323,60.621778,68.582540,78.287693,88.561119,\
        98.156743,106.007043,111.428222,114.237346,114.756729,113.706291,112.009861,110.560634,110.000000,110.560634,112.009861,\
        113.706291,114.756729,114.237346,111.428222,106.007043,98.156743,88.561119,78.287693,68.582540,60.621778,55.274323,52.928233,\
        53.418823,56.074110,59.866963,63.639610,66.350198,67.286436,66.199152,63.326941,59.307883,55.000000,51.252751,48.682920,\
        47.507139,47.470293,47.887148,47.788611,46.140080,42.082633,35.142296,25.359460,13.308217,0.000000,-13.308217,-25.359460,\
        -35.142296,-42.082633,-46.140080,-47.788611,-47.887148,-47.470293,-47.507139,-48.682920,-51.252751,-55.000000,-59.307883,\
        -63.326941,-66.199152,-67.286436,-66.350198,-63.639610,-59.866963,-56.074110,-53.418823,-52.928233,-55.274323,-60.621778,\
        -68.582540,-78.287693,-88.561119,-98.156743,-106.007043,-111.428222,-114.237346,-114.756729,-113.706291,-112.009861,\
        -110.560634,-110.000000,-110.560634,-112.009861,-113.706291,-114.756729,-114.237346,-111.428222,-106.007043,-98.156743,\
        -88.561119,-78.287693,-68.582540,-60.621778,-55.274323,-52.928233,-53.418823,-56.074110,-59.866963,-63.639610,-66.350198,\
        -67.286436,-66.199152,-63.326941,-59.307883,-55.000000,-51.252751,-48.682920,-47.507139,-47.470293,-47.887148,-47.788611,\
        -46.140080,-42.082633,-35.142296,-25.359460,-13.308217,
    };
    
    //fft算法来自开源 https://github.com/xiahouzuoxin/fft
    
    const float sin_tb[] =    // 精度(PI PI/2 PI/4 PI/8 PI/16 ... PI/(2^k))
    {
            0.000000, 1.000000, 0.707107, 0.382683, 0.195090, 0.098017,
            0.049068, 0.024541, 0.012272, 0.006136, 0.003068, 0.001534,
            0.000767, 0.000383, 0.000192, 0.000096, 0.000048, 0.000024,
            0.000012, 0.000006, 0.000003
            };
    
    const float cos_tb[] =    // 精度(PI PI/2 PI/4 PI/8 PI/16 ... PI/(2^k))
    {
            -1.000000, 0.000000, 0.707107, 0.923880, 0.980785, 0.995185,
            0.998795, 0.999699, 0.999925, 0.999981, 0.999995, 0.999999,
            1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
            1.000000, 1.000000, 1.000000
            };
    
    
    int ones_32(uint32_t n)
    {
        unsigned int c = 0 ;
        for(c = 0; n; ++c)
        {
            n &= (n - 1) ;
        }
    
        return c ;
    }
    
    
    uint32_t floor_log2_32(uint32_t fft_buff)
    {
        fft_buff |= (fft_buff >> 1);
        fft_buff |= (fft_buff >> 2);
        fft_buff |= (fft_buff >> 4);
        fft_buff |= (fft_buff >> 8);
        fft_buff |= (fft_buff >> 16);
    
        return (ones_32(fft_buff >> 1));
    }
    
    
    /*
     * FFT Algorithm
     * === Inputs ===
     * fft_buff : complex numbers
     * N : nodes of FFT. @N should be power of 2, that is 2^(*)
     * === Output ===
     * the @fft_buff contains the result of FFT algorithm, so the original data
     * in @fft_buff is destroyed, please store them before using FFT.
     */
    int fft(TYPE_FFT *fft_buff, uint32_t N)
    {
        int i, j, l, k, ip;
        static uint32_t M = 0;
        static int le, le2;
        static TYPE_FFT_E sR, sI, tR, tI, uR, uI;
    
        M = floor_log2_32(N);
    
        /*
         * bit reversal sorting
         */
    
        l = N >> 1;
        j = l;
        ip = N - 2;
        for(i = 1; i <= ip; i++)
        {
            if(i < j)
            {
                tR = fft_buff[j].real;
                tI = fft_buff[j].imag;
                fft_buff[j].real = fft_buff[i].real;
                fft_buff[j].imag = fft_buff[i].imag;
                fft_buff[i].real = tR;
                fft_buff[i].imag = tI;
            }
    
            k = l;
    
            while(k <= j)
            {
                j = j - k;
                k = k >> 1;
            }
    
            j = j + k;
        }
    
        /*
         * For Loops
         */
    
        for(l = 1; l <= M; l++)  /* loop for ceil{log2(N)} */
        {
            le  = (int)(1 << l);
            le2 = (int)(le >> 1);
            uR = 1;
            uI = 0;
    
            k = floor_log2_32(le2);
            sR = cos_tb[k];
            sI = -sin_tb[k];
    
            for(j = 1; j <= le2; j++)  /* loop for each sub DFT */
            {
                for(i = j - 1; i < N; i += le) /* loop for each butterfly */
                {
                    ip = i + le2;
                    tR = fft_buff[ip].real * uR - fft_buff[ip].imag * uI;
                    tI = fft_buff[ip].real * uI + fft_buff[ip].imag * uR;
                    fft_buff[ip].real = fft_buff[i].real - tR;
                    fft_buff[ip].imag = fft_buff[i].imag - tI;
                    fft_buff[i].real += tR;
                    fft_buff[i].imag += tI;
                }  /* Next i */
    
                tR = uR;
                uR = tR * sR - uI * sI;
                uI = tR * sI + uI * sR;
    
            } /* Next j */
    
        } /* Next l */
    
        return 0;
    }
    
    
    /*
     * Inverse FFT Algorithm
     * === Inputs ===
     * fft_buff : complex numbers
     * N : nodes of FFT. @N should be power of 2, that is 2^(*)
     * === Output ===
     * the @fft_buff contains the result of FFT algorithm, so the original data
     * in @fft_buff is destroyed, please store them before using FFT.
     */
    
    int ifft(TYPE_FFT *fft_buff, uint32_t N)
    {
        int k = 0;
    
        for(k = 0; k <= N - 1; k++)
        {
            fft_buff[k].imag = -fft_buff[k].imag;
        }
    
        fft(fft_buff, N);    /* using FFT */
    
        for(k = 0; k <= N - 1; k++)
        {
            fft_buff[k].real = fft_buff[k].real / N;
            fft_buff[k].imag = -fft_buff[k].imag / N;
        }
    
        return 0;
    }
    
    static void import_data(void)
    {
        int i;
    
        for(i = 0; i < SAMPLE_NODES; i++)
        {
            fft_buff[i].real = my_sin_wave_table[i];//取前1024个数进行fft变换
            fft_buff[i].imag  = 0.0f;
        }
    }
    
    
    int main(int argc, char *argv[])
    {
        int i;
        int f;//频率
        float a;//幅度
        int fd;
        float t;
    
        printf("FFT\r\n");
    
        import_data();
    
        fft(fft_buff, SAMPLE_NODES);
    
        //fft后的结果在fft_buff
        //将其实部与虚部处理,输出频点与幅度值,导入Excel看效果
        //因为是周期性质,取前半部分即可
    
        //数据采样频率是360*40,均分到SAMPLE_NODES,则对应频点间隔是 360*40/SAMPLE_NODES
        fd=360*40/SAMPLE_NODES;
    
        for(i = 0; i < SAMPLE_NODES / 2; i++)
        {
            f = i *fd;
            a = (double)sqrt(fft_buff[i].real * fft_buff[i].real + fft_buff[i].imag * fft_buff[i].imag)/ (SAMPLE_NODES / 2);//转换幅度
            //printf("%d,%f\n", f, a);//>>导入excel查看幅频图效果
        }
    
        //过滤高频部分
        //将幅度小于某个值的,以30为例过滤
        for(i = 0; i < SAMPLE_NODES; i++)
        {
            a = (double)sqrt(fft_buff[i].real * fft_buff[i].real + fft_buff[i].imag * fft_buff[i].imag)/ (SAMPLE_NODES / 2);
            if(a<30)
            {
                fft_buff[i].real = 0;
                fft_buff[i].imag = 0;
            }
        }
    
        //再进行逆运算还原
        ifft(fft_buff, SAMPLE_NODES);
        for(i = 0; i < SAMPLE_NODES; i++)
        {
            t=1.0/(360*40)*i;//结合采样频率步进,方便查看波形效果
            //printf("%f,%f\n", t,fft_buff[i].real);//>>导入excel查看还原后的sin效果
        }
    
        return 0;
    }
    

    五、应用

       傅里叶变换在数字信号领域中应用广泛,在嵌入式系统中,一般用来分析ADC高速采集的数据、滤波处理,或者对音频进行简单分析。但傅里叶变换算法内存消耗有点大,低端设备可能无法运行。

    展开全文
  • 稀疏快速傅里叶变换算法
  • #ffo.py 快速傅立叶正交化 和快速傅立叶最近平面算法 提出的算法的Python实现 [Ducas and Prest: : ] ... 它不打算被原样使用,而是提供对相关论文的权利要求的健全性检查,并且可以用作更快语言的实现的参考。
  • 提出了一种应用快速傅里叶变换算法提高哈特曼夏克波前传感器波前重构实时性的快速算法。在根据波前斜率值应用最小二乘法估计波前相位的过程中,应用快速傅里叶变换算法进行方程的对角化和相位值的解耦,算法精度高、...
  • 在STM32单片机上计算一组数据的频域值

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 24,316
精华内容 9,726
热门标签
关键字:

傅里叶算法的使用

友情链接: MFC.rar