I am getting an error that matlab does not recognize the function filter1 even though it is a matlab built-in function
Show older comments
%% Lab 3 Part 3
clc
clear
clf
% reads given audio file and puts it into y at frequency Fs
[y, Fs] = audioread('song_original.wav');
% starts playing original sound
%{
disp('sound start');
sound(y);
pause(10);
clear sound
disp('sound end');
%}
%% FFT
Z = fft(y);
t = (0:length(y)-1)/Fs;
t = transpose(t);
FD = 1/(mean(diff(t)));
L = numel(Z);
P2 = abs(Z/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = FD*(0:(L/2))/L;
%% Plot original sound file
plot(t,y,'k-','linewidth',1)
box off;
axis tight
xlabel 'time (seconds)'
%% Low Pass Filter
ylp = filterl('lp',y,'x',t,'fc',1100);
hold on
plot(t,ylp,'b')
Warning: Integer operands are required for colon operator when used
as index.
> In Lab3Part32 (line 25)
Undefined function or variable 'filterl'.
Error in Lab3Part32 (line 38)
ylp = filterl('lp',y,'x',t,'fc',1100);
>>
Answers (2)
Voss
on 20 Oct 2022
0 votes
filter1 is not a built-in function, but it is available on the File Exchange:
Download that, put it on your path, and try running your code again.
Image Analyst
on 20 Oct 2022
0 votes
I tried both filter1 ("one") and filterl ("L"). I'm not seeing either one in base MATLAB. It must be some function that you got (or thought you got) from somewhere or someone. Ask your professor for it. If he gave you a folder of utilities for your lab, then you must set a path to that folder.
Categories
Find more on Audio Processing Algorithm Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!