issues with making a matlab firfilter
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to write a matlab code to design a firfilter but I am having trouble getting the filter to work this code below is supposed to determine the frequencies and filter them out of the sunshinesquare.wav file. however when I go to run the program matlab tells me there is an error with the notchfilter line but I can't figure out what is wrong with it any suggestions/help is greatly appreciated.
My code is below
[x, fs] = audioread('SunshineSquare.wav');
X = fft(x);
f = linspace(0, fs/2, length(X)/2);
[~, f0] = max(abs(X(1:length(X)/2)));
notchFilter = fdesign.notch('N,Fc', 100, f0, fs);
b = firpm(notchFilter);
y = filter(b, 1, x);
sound(x, fs);
0 Kommentare
Antworten (1)
Chunru
am 27 Nov. 2023
%[x, fs] = audioread('SunshineSquare.wav');
load handel.mat
audiowrite("handel.wav", y, Fs);
[x, fs] = audioread('handel.wav');
X = fft(x);
f = linspace(0, fs/2, length(X)/2);
[~, f0] = max(abs(X(1:length(X)/2)));
f = (f0-1)/fs; % the corresponding freq for index f0
notchFilter_spec = fdesign.notch('N,F0,Q', 100, f, 10, fs/2); %
notchFilter = design(notchFilter_spec, 'Systemobject', true)
% fvtool(notchFilter)
y = notchFilter(x);
%y = filter(b, 1, x);
% sound(x, fs);
subplot(211); plot(x);
subplot(212); plot(y)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Digital Filter Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!