How does phasez work?

6 ビュー (過去 30 日間)
Nathan Jessurun
Nathan Jessurun 2018 年 12 月 10 日
I thought phasez simply plots the unwrapped version of a filter's angle. However, I get different plots for the following methods:
% Filter to add reverb to sample -- Requires DSP toolbox
% Use the impulse response from a reverb-y building as the time domain filter impulse repsonse
[timeFilter, Fs] = audioread('ChurchImpulseResponse-16-44p1-mono-5secs.wav');
% For an FIR filter, the time domain coefficients are the taps of the filter
h = freqz(timeFilter, [1 zeros(1, length(timeFilter))]);
[phi, w] = phasez(h);
plot(w, phi);
hold on;
plot(w, unwrap(angle(h)));
xlabel('frequency (rad/sample)');
ylabel('phase (radians)')
legend({'phasez', 'unwrap(angle)'});
What causes these two plots to behave quite differently for the produced filter? Note that for most filters I've tried, these plot operations are synonymous.Capture.PNG

採用された回答

Miriam Guadalupe Cruz Jimenez
Miriam Guadalupe Cruz Jimenez 2019 年 8 月 13 日
Hi! Indeed 'phasez()' plots the unwrapped angle, but 'phasez()' acts on the coefficients of the filter and 'unwrap(angle())' acts on the frequency response of the filter. Thus, in your code you should employ 'timeFilter' as the argument in 'phasez()' and 'h' as the argument of 'unwrap(angle())'. Attached your sample code with this modification.
timeFilter = [1 2 3 4 5 6 7 8 9];
h = freqz(timeFilter, [1 zeros(1, length(timeFilter))]);
[phi, w] = phasez(timeFilter);
plot(w, phi);
hold on;
plot(w, unwrap(angle(h)),'o');
xlabel('frequency (rad/sample)');
ylabel('phase (radians)')
legend({'phasez', 'unwrap(angle)'});

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by