Is centredFFT function really exist?
이전 댓글 표시
i try to run this code that i get from a website. however, the MATLAB cannot read the "centeredFFT" whenever i try to enter this line: function [X,f] = centeredFFT(x,Fs); it will return this line: ??? Undefined function or method 'centeredFFT' for input arguments of type 'double'. may i know what is the reason behind this?
i am thinking that i need to use extra toolbox, which i don't know its name.
below is the code
[y,Fs,bits] = auread('bird_chirping2.au');
x = y(:,1);
clear y; N = length(x);
time = [1:N].*(1/Fs);
han = plot(time,x); xlab = xlabel('Seconds'); ylab = ylabel('Amplitude'); grid on; set(han,'LineWidth', 2); set([xlab, ylab],'FontSize', 24, 'FontName', 'Times'); set(gca,'FontSize',20,'FontName','Times','Fontweight','Bold')
% wavwrite(x,Fs,bits,'test.wav');
[X,f] = centeredFFT(x,Fs);
figure; han1 = plot(f,abs(X)); axis([-8000,8000,0,max(abs(X))]); grid on; xlab1=xlabel('Frequency(Hz)'); ylab1=ylabel('|X[k]|'); set(han1,'LineWidth', 2); set([xlab1, ylab1],'FontSize', 24, 'FontName', 'Times'); set(gca,'FontSize',20,'FontName','Times','Fontweight','Bold')
% sound(x,Fs,bits);
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
fc = 2000; fNorm = fc / ( Fs/2); [b,a] = butter(10, fNorm, 'low'); x_Low = filtfilt(b, a, x);
figure; freqz(b,a,bits,Fs/2); grid on;
% sound(x_Low,Fs,bits); % wavwrite(x_Low,Fs,bits,'x_Low_.wav');
[X_LOW,f_low] = centeredFFT(x_Low,Fs);
figure; han2=plot(f_low,abs(X_LOW)); axis([-.8e4,.8e4,0,max(abs(X))]); grid on; xlab2=xlabel('Frequency(Hz)'); ylab2=ylabel('|X[k]|)'); set(han2,'LineWidth', 2); set([xlab2, ylab2],'FontSize', 24, 'FontName', 'Times'); set(gca,'FontSize',20,'FontName','Times','Fontweight','Bold')
figure; han3=plot(time,x_Low); grid on; xlab3=xlabel('Frequency(Hz)'); ylab3=ylabel('|X[k]|)'); set(han3,'LineWidth', 2); set([xlab3, ylab3],'FontSize', 24, 'FontName', 'Times'); set(gca,'FontSize',20,'FontName','Times','Fontweight','Bold')
채택된 답변
추가 답변 (1개)
Can Matlab find your downloaded function?
which centeredFFT
If not, move your function to your current directory or another directory in Matlab's search path.
카테고리
도움말 센터 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!