필터 지우기
필터 지우기

calculate frequency response from two signal on domain time in matlab

조회 수: 48 (최근 30일)
Alex Dashevsky
Alex Dashevsky 2018년 1월 2일
편집: Nghi Nguyen 2020년 9월 4일
Hi, I have arrays sample in time domain of input and output signal. size of vector is 2002 samples. I want to find frequency response. I wrote [h,w] = freqz(y,x,2002); figure() plot(abs(h)) but I get very strange graph. I assume to see filter. I want to calculate frequency response of smartphone(Audio filter) What do I do wrong ?
  댓글 수: 2
Alex Dashevsky
Alex Dashevsky 2018년 1월 2일
편집: Alex Dashevsky 2018년 1월 2일
x is input and y is output
[h,w] = freqz(x,y,2002); plot(abs(h))

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2018년 1월 2일
You cannot get any useful information from your data because of the noise. However, with the correct sampling frequency (you did not state that or give a time vector), this will give you all the information it is possible to get from your data:
D1 = load(x.mat);
D2 = load(y.mat);
x = D1.x;
y = D2.y;
L = numel(x); % Length Of Signal
Fs = 1; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTx = fft(x)/L;
FTy = fft(y)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
TFyx = FTy./FTx;
figure(1)
subplot(2,1,1)
semilogx(Fv, 20*log10(abs(TFyx(Iv))))
ylabel('|H(f)| (dB)')
subplot(2,1,2)
semilogx(Fv, angle(TFyx(Iv))*180/pi)
ylabel('Phase (°)')
xlabel('Frequency (Hz)')
Note that you are only using one frequency, so if you want the frequency response at that frequency, divide the amplitude of ‘y’ by the amplitude of ‘x’. If you want the frequency response, the input must either be a sweep signal (such as a chirp) or broadband noise (essentially an impulse response). When you do that, my code will work for a broadband input signal producing a broadband output signal.
  댓글 수: 16
Omar
Omar 2019년 3월 24일
Hello Star Strider,
Could you please advise me why you chose Nyquist Frequency (Fn) to clacualte the frequency vector not the sampling frequency Fs itself in this example.
Please tell me.
Nghi Nguyen
Nghi Nguyen 2020년 9월 4일
편집: Nghi Nguyen 2020년 9월 4일
Hello Star Strider,
May I have a question about the unit of the x-axis? Why is it in Hz, but not in rad/s?
Thank you very much.
Nghi

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by