简单的包络检波

这篇博客介绍了简单的包络检波原理,通过比较输入信号Ui(t)和输出信号Uo(t-)的大小来更新输出。当输入大于输出时,输出等于输入;否则,利用RC电路的特性更新输出。博主通过解析差分方程,展示了如何将这一过程转化为编程代码。

当 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; 
end
subplot(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;  
%         }  
%     }  
% }  

这里写图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值