简单的包络检波

来源:互联网 发布:手机视频直播app源码 编辑:程序博客网 时间:2024/06/06 01:02

当 Ui(t) > Uo(t-) 时 Uo(t) = Ui(t)
当 Ui(t) < Uo(t-) 时
RC dUo/dt = Uo
化成差分方程为:
这里写图片描述
把这个过程用程序来实现就有了下面的代码。

clear all;x = 0:0.000001:0.005;y = sin(200000.*pi.*x) .* (sin(2000.*pi.*x)*0.2 + 0.5);mold = 0.0;out = x;rc = 400;for i=1:5000    if y(i) > mold        mold = y(i);    else        mold = (mold * rc)/(rc + 1);    end    out(i) = mold; endsubplot(211);plot(y);subplot(212);plot(out);% 半波% void env_half(double in[], double out[], int N)  % {  %     for(int i = 0; i < N; i++)  %     {  %         if( in[i] > m_old)  %         {  %             m_old = in[i];  %             out[i] = m_old;  %         }  %         else  %         {  %             m_old *= m_rct / ( m_rct + 1 );  %             out[i] = m_old;  %         }  %     }  % } % 全波% void env_full(double in[], double out[], int N)  % {  %     double abs_in;  %     for(int i = 0; i < N; i++)  %     {  %         abs_in = fabs(in[i]);  %         if( abs_in > m_old)  %         {  %             m_old = abs_in;  %             out[i] = m_old;  %         }  %         else  %         {  %             m_old *= m_rct / ( m_rct + 1 );  %             out[i] = m_old;  %         }  %     }  % }  

这里写图片描述