error matrix dimensions must agree designing yulewalk filter
1 view (last 30 days)
Show older comments
Hi,
I am desiging a yulewalk filter to filter out the noise from input sound and detects the desired signal. Am attaching the code for function named designfilter that i am using in my code. It uses the magnitude values of the averaged noise frequency response in order to design the filter. But am having the error in code line
M=[-data(points)'-data(points2)'];
"matrix dimensions must agree"
can anyone help me out that where am doing it wrong
both the audio files as wav format are attached.
code for designfilter function
function [Hz,filter]=designfilter(finalnoise,freq,fs);
N=10;
const=fs/2;
%power spectral density
nfft=2^nextpow2(length(finalnoise));
pfs=abs(fft(finalnoise,nfft)).^2/length(finalnoise)/fs;
HpsdIS=dspdata.psd(pfs(1:length(pfs)/2),'Fs',fs);
%yulewalk filter
data=10*log10(HpsdIS.data);
points=round(linspace(1,230,230));
points2=round(linspace(231,512,50));
F=[(freq(points)*1000)/const (freq(points2)*1000)/const];
M=[-data(points)'-data(points2)'];
filter=struct('F',F,'M',M);
Hz=yulewalk(N,F,M);
end
here is my code where i am using designfilter function
[sound,fs]=audioread('noise.wav');
[wail,fs]=audioread('ambulancewail.wav');
bufferpos=0;
buffersize=5;
window=1024;
loop=round(length(sound)/window)-1;
%% noise buffer
noisebuffer(:,1)=sound((1:window),1);
for n=2:buffersize
noisebuffer(:,size(noisebuffer,2)+1)=sound((((n-1)*window)+1:n*window),1);
end
finalnoise=sum(noisebuffer,2)./buffersize;
%%
N = length(finalnoise);
xdft = fft(finalnoise);
xdft = xdft(1:N/2+1);
psdx = (1/(fs*N)) * abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:fs/length(finalnoise):fs/2;
plot(freq,10*log10(psdx))
grid on
title('Periodogram Using FFT')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency (dB/Hz)')
%% filter design
[Hz,filters(1).filter]=designfilter(finalnoise,freq,fs);
0 Comments
Answers (0)
See Also
Categories
Find more on Digital Filter Design in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!