How can I use the envelope function for the following plot?

Hello!
I'm extremely new to Matlab and really need some help to implement my project!
How is it possible to smoothen the set of data on this plot- enclosed screen shot (initially it is a signal, .wav file)? I tried using envelope function, slmengine, hilbert but still of no use.
I also tried getting rid of the inf values and using filtering to make the further processing of the data easier.
Any help appreciated. My little code is below.
file = '/Users/mac/Desktop/clap101cm.wav';
[wave,Fs] = audioread(file);
sound(wave,Fs);
Nsamps = length(wave);
t = (1/Fs)*(1:Nsamps);
ydb = mag2db(wave);
new_sound = ydb(:,1);
smtlb = sgolayfilt(new_sound,3,11);
smtlb(isinf(smtlb))=NaN;
plot(t, smtlb);
windowSize =length(smtlb);
b = (1/windowSize)*ones(1,windowSize);
a = 1;
y = filter(b,a,smtlb);
hold on
plot(t,y)
grid on
xlabel('Time (s)')
ylabel('Amplitude, (dB)')
title('Clap decay.big')

回答 (1 件)

Image Analyst
Image Analyst 2015 年 8 月 4 日
編集済み: Image Analyst 2015 年 8 月 4 日

0 投票

You forgot to attach your data in a .mat file. How about using sgolayfilt() if you have the Signal Processing Toolbox. It fits the data in a sliding window to a polynomial. You have control over the window size and polynomial order. There are other methods based on frequency like butterworth or Fourier filtering. It's a sound file - why do you need to smooth it?

4 件のコメント

Daria Nasledysheva
Daria Nasledysheva 2015 年 8 月 21 日
thank you for your answer, sorry for such a delay in replying- had no computer for a while. I used sgolayfilt in my code but it didnt seem to filter the data though or I was just doing the wrong thing. I need to smooth it, so that I will be able to connect the upper knots and get a plot of it, receiving a simplified model of a signal and further implement my calculations...
And I have a further question: how is it possible to adjust the data, so that 0 is the level of silence?
Hoping for your help!!!
Image Analyst
Image Analyst 2015 年 8 月 21 日
Didn't really help. I was trying to imply that if you attached your data in a .mat file, someone may be able to try something with it. Without data, you're not making it easy for anyone to help you.
Daria Nasledysheva
Daria Nasledysheva 2015 年 8 月 24 日
The data from this code is attached here. Thank you
Muthu Annamalai
Muthu Annamalai 2015 年 8 月 24 日
How about using a low pass filter ?

サインインしてコメントする。

カテゴリ

タグ

タグが未入力です。

質問済み:

2015 年 8 月 4 日

コメント済み:

2015 年 8 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by