bandpass.m.svn-base

来自「a function inside machine learning」· SVN-BASE 代码 · 共 28 行

SVN-BASE
28
字号
function output_wave = bandpass(wave_vector, low_pass, high_pass, sampling_rate);
%Does some band pass filtering on the data 
%inputs
%wave vector is a row vector of the input waveform 
%low_pass is the low pass frequency in Hz
%high_pass is the high pass frequency in Hz 
%sampling rate is rate of sampling in Hz

%outputs 
%output_wave 

wave_samples = size(wave_vector, 2); 

fourier = fft(wave_vector); 

%Filter out the frequencies
%The maximum frequency we can have is equal to the sampling rate and we
%have wave_samples frequencies, so each element of the fft is
%sampling/wave_samples Hz. 

for(i=1:wave_samples) 
    if(i*(sampling_rate/wave_samples) < low_pass || i*(sampling_rate/wave_samples) > high_pass)
        fourier(i) = 0; 
    end 
end

output_wave = real(ifft(fourier)); 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?