calculate frequency response from two signal on domain time in matlab
32 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 2 Gen 2018
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 Commenti
Omar
il 24 Mar 2019
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
il 4 Set 2020
Modificato: Nghi Nguyen
il 4 Set 2020
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
Vedere anche
Categorie
Scopri di più su Cepstral Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!