Finding the best parameters for Savitzky-Golay filter
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147180/image.jpeg)
0 件のコメント
回答 (2 件)
3 件のコメント
HOW TO KNOW THE ORDER AND FRAMELENGTH ??
clc
clear all
close all
[x,fs]=audioread('Record_0001.wav'); %load the sound
sound(x,fs)
pause(3)
figure(1)
plot(x)
x = x+(randn(size(x)));
figure(2)
plot(x)
sound (x,fs);
pause(3)
order = 8;
framelen = 21;
b = sgolay(order,framelen);
y = conv(x,b((framelen+1)/2,:),'valid');
z = b(end:-1:(framelen+3)/2,:) * x(framelen:-1:1);
z1 = b((framelen-1)/2:-1:1,:) * x(end:-1:end-(framelen-1));
sound(x)
z3 = sgolayfilt(x,7,41);
y = [z; y; z1];
figure(3)
plot([x y])
legend('Noisy Sinusoid','S-G smoothed sinusoid')
figure(4)
sound(z3,fs)
subplot(2,1,1) plot(1:2000, x(1:2000)) axis([0 2000 -4 4]) title('mtlb') grid
subplot(2,1,2) plot(1:2000,z3(1:2000)) axis([0 2000 -4 4])
title('smtlb') grid
graph_of_input_speech
![](/matlabcentral/answers/uploaded_files/100635/graph_of_input_speech.jpg)
graph_of_input_speech_with_noise
![](/matlabcentral/answers/uploaded_files/100638/graph_of_input_speech_with_noise.jpg)
graph after using sgolay
![](/matlabcentral/answers/uploaded_files/100641/using_sgolayfilt.jpg)
couldn't get desired output
![](/matlabcentral/answers/uploaded_files/100640/couldn't_gt_desired_output.jpg)
1 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!