Info

This question is closed. Reopen it to edit or answer.

envelope detection false amplitude problem

1 view (last 30 days)
geem
geem on 30 Jun 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi all; ı used matlab envelope detection simulink modal(squaring signal and low pass filtering ) and adapted for my wav data. It works but amplitude sometimes can't follow well. So can anyone suggest me about why it is happening?
function [sigenv1,sigenv1y] = zarfsimu(data,fs) %% Envelope Detection
le_data = length(data);
if le_data<1500 DownsampleFactor=3; end if le_data>=1500&&le_data<=2000 DownsampleFactor=round(le_data/375); end if le_data>2000&&le_data<=2500 DownsampleFactor=round(le_data/400); end if le_data>2500&&le_data<=3000 DownsampleFactor=round(le_data/400);end if le_data>3000&&le_data<=3500 DownsampleFactor=round(le_data/400);end if le_data>3500&&le_data<=4000 DownsampleFactor=round(le_data/400);end if le_data>4500 DownsampleFactor=round(le_data/1125);end
numSamples = 10000;% max sample frameSize = 10*DownsampleFactor; Fs=fs; hsin=dsp.SignalReader(data); %systemobject for data
for i=1:numSamples/frameSize
sig=data;
sigsq = 4*sig.*sig; %normally squaring data but i prefer four
%a=downsample(sigsq, DownsampleFactor); %downsampling
%hm = mfilt.firdecim(15);
hm = mfilt.firsrc(1,DownsampleFactor,[1 1]);
des=filter(hm,sigsq);
%low pass
a1= firpm(30, [0 0.003 0.1 1], [1 1 0 0]);
len_des=length(des);
len=mod(len_des,length(a1));
%if len ~= 0
%add=length(a1)-len;
add=15; % for plotting
all=len_des+add;
des2=zeros(all,1);
des2(1:len_des,1)=des;
a2=filter(a1,1,des2);
%a=step(hlowpass1,des);
sigenv1 = sqrt(a2);
sigenv1y=sigenv1(15:end,1);
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!