calculate frequency response from two signal on domain time in matlab

38 ビュー (過去 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 件のコメント
Birdman
Birdman 2018 年 1 月 2 日
Can you share your file?
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