[英]implementing a filter from its frequency response in MATLAB
我一直在嘗試在MATLAB上實現此濾波器,但我只知道它的頻率響應為:HW =((3 * c * 1i *(J0))./(2 * rfg * W))+(((3 * 2 * RFG *(W. * J1)) - (3 * 3 * C * * 1I J1))./(2 * 拉姆達 RFG * W. ^ 2))其中,J0和J1是為了0球形貝塞爾函數和1。
如何使用它的頻率響應在時域中實現它?
a = 0.1; %radius of a spherical zone in m
%Data
c = 344; %speed of sound
rf = 3; %location of primary sound source
phi_f = degtorad(0); % "
rg = 1; %location of secondary sound source
phi_g = degtorad(45); % "
rfg = 1/((1/rg)-(1/rf));
lambda = - (2/c) * sin( (phi_f - phi_g)/2 );
F=0:.1:10000; %Frequency in Hertz
W = 2*pi*F; %Angular frequency vector (rad/sec)
%Bessel Functions
J0 = sphbes(0, a*lambda*W);
J1 = sphbes(1, a*lambda*W);
%Filter
HW= ( (3*c*1i*(J0))./(2*rfg*W) ) + (( (3*2*rfg*(W.*J1))-(3*3*c*1i*J1) ) ./ (2*a*lambda*rfg*W.^2) );
謝謝。
這是你想要的?
a = 0.1; %radius of a spherical zone in m
%Data
c = 344; %speed of sound
rf = 3; %location of primary sound source
phi_f = degtorad(0); % "
rg = 1; %location of secondary sound source
phi_g = degtorad(45); % "
rfg = 1/((1/rg)-(1/rf));
lambda = - (2/c) * sin( (phi_f - phi_g)/2 );
Fs = 20000; % Sampling frequency (largest frequency in the frequency domain)
dt = 1/Fs; % Sampling time step (period)
N = 200000; % Number of points in the signal
t = (0:N-1)*dt; % Time vector
df = 1/(N*dt); % Frequency step
f = 0:df:(Fs/2); % Frequency vector in Hz
W = 2*pi*f; %Angular frequency vector (rad/sec)
%Bessel Functions
J0 = sphbes(0, a*lambda*W);
J1 = sphbes(1, a*lambda*W);
% Filter
HW = ( (3*c*1i*(J0))./(2*rfg*W) ) + (( (3*2*rfg*(W.*J1))-(3*3*c*1i*J1) ) ./ (2*a*lambda*rfg*W.^2) );
HW(1) = HW(2); % the value is NaN at f = 0
% visualising
figure(1);
cla(gca);
hold on;
plot(f, real(HW));
plot(f, imag(HW));
plot(f, abs(HW));
hold off;
xlabel('Frequency (Hz)');
ylabel('Amplitude');
legend({'Real', 'Imaginary', 'Absolute'});
box on;
% Convert from single sided to two sided
P1 = HW;
P1_flipped = fliplr(P1);
P2 = [P1(1:end-1) P1_flipped(1:end-1)];
P2 = P2/2;
% do the inverse fft
time_domain = ifft(P2);
% visualising
figure(2);
cla(gca);
hold on;
plot(t*1000, real(time_domain));
plot(t*1000, imag(time_domain));
plot(t*1000, abs(time_domain));
hold off;
xlabel('time (msec)');
ylabel('Amplitude');
legend({'Real', 'Imaginary', 'Absolute'});
box on;
xlim([0 10]);
ylim([-18*10^(-5) 18*10^(-5)]);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.