• [Matlab]傅立叶级数叠加合成周期矩形脉冲波形失败-已解决 Sa函数和sinc函数的区别


    理论依据:

    其傅立叶级数分解形式为:

    matlab代码:

    %三角形式
    %%使用傅立叶级数合成周期矩形脉冲。todo:失败
    clc;
    clear ;
    close all;
    %参数
    E = 1;    %幅值
    tao = 2;  %脉冲宽度
    T = 5;    %总的周期
    omega = 2*pi/T;
    t = -10:0.01:10;
    level = 100; %100阶合成
    f = zeros(1,length(t));
    for n = 0:level %阶数
        for s = 1 : length(t)
            if( n == 0 ) %第0阶
                f(s) = f(s)+ E*tao/T;
            end
            if( n > 0 ) %非0阶
                f(s) = f(s) + 2*E*tao*sinc(n*omega*tao/2)*cos(n*omega*t(s))/T;
            end
        end
    end
    figure(1);
    
    plot(t,f);
    title('三角函数形式100阶模拟	au = 2 E = 1 T1 = 5');
    axis([ -10 10 -0.1 1 ]);
    set(gca,'xtick',[-10:10]);
    

      

    %指数形式
    clc;
    clear;
    close all;
    E = 1;
    tao = 2;
    T1 = 5;
    w = 2*pi/T1;
    t = -10:0.01:10;                %自变量区间
    level = 100;                    %阶数
    ft = zeros(1,length(t));        %函数值存放位置
    for n = -level:level
        for s = 1:length(t);
            fn = E*tao/T1*sinc(n*w*tao/2);
            ft(s)=ft(s) + fn*exp(1i*w*n*t(s));
        end
    end
    figure();
    plot( t , abs(ft));
    title('指数函数形式100阶模拟	au = 2 E = 1 T1 = 5');
    axis([ -10 10 -0.1 1 ]);
    set(gca,'xtick',[-10:10]);
    

    模拟结果:三角形式和指数形式的叠加结果一致:幅值不对,脉宽不对

      

    错误原因:

     公式应当修改多除以一个pi。

    运算代码修改为:

    %三角形式
    for n = 0:level %阶数
            if( n == 0 ) %第0阶
                f = f+ E*tao/T;
            end
            if( n > 0 ) %非0阶
                %f = f + 2*E*tao*sinc(n*omega*tao/2)*cos(n*omega*t)/T;
                f = f + 2*E*tao*sinc(n*omega*tao/(2*pi))*cos(n*omega*t)/T;
                %f = f + 2*E*tao/T*sinc(n*tao/T)*cos(n*omega*t);
            end
    end
    %指数形式
    for n = -level:level
            fn = E*tao/T1*sinc(n*tao/T1);
            ft=ft + fn*exp(1i*w*n*t);
    end
    

      

    ~不再更新,都不让我写公式,博客园太拉胯了
  • 相关阅读:
    T4模板+Web.config连接SqlServer+DBManage.cs+DbHelper.cs
    MVCApplication
    MVC路由(Route)
    过滤器+用session验证是否登陆过
    前台.cshtml得到session值方法
    C++ sort() method with 1.default operator,2 stand library compare ,3custom function,4,lambda expression
    C++ boost serialize struct to text
    C++ multi thread via pthread to retrieve returned result
    C++ pthread create and join
    C++ write and read file via fstream in ios::out,ios::in,ios::app mode
  • 原文地址:https://www.cnblogs.com/alimy/p/8989362.html
Copyright © 2020-2023  润新知