Functions | |
elseif (nargin==1) a | |
if (!ischar(region)&&!isempty(region)) Fs | |
endif endif | if (isempty(b)) b |
endif | if (isempty(a)) a |
endif | if (isempty(n)) n |
endif | if (isempty(region)) if(isreal(b)&&isreal(a)) region |
endif endif | if (isempty(Fs)) if(nargout |
if (!isscalar(n)) w | |
if (nargin==4) w | |
if (k > n/2 &&nargout==0) n | |
endif | if (strcmp(region,"whole")) N |
if (nargout!=0) h_r | |
else | freqz_plot (f, h) |
!assert (h(1), 1, 10 *eps) | |
!assert (abs(h(17)).^2, 0.5, 10 *eps) | |
!assert (h, freqz(b, a, w), 10 *eps) | |
!assert (h(2:16), conj(h(32:-1:18)), 20 *eps) | |
!assert (h(1:16), h2, 20 *eps) | |
!assert (w(1:16), w2, 20 *eps) | |
!assert (f,[0:15]'*10, 10 *eps) | |
!assert (f2,[0:15]*10, 10 *eps) | |
!assert (h, h2.', 20 *eps) | |
!assert (f3,[0:31]'*10, 10 *eps) | |
Variables | |
function [h_r, f_r] | |
region = [] | |
else | Fs = 2*pi |
endif endif | a = a(:) |
b = b(:) | |
endif | k = max (length (b), length (a)) |
hb = polyval (postpad (b, k), exp (j*w)) | |
ha = polyval (postpad (a, k), exp (j*w)) | |
else | N = 2*n |
endif | f = Fs * (0:n-1).' / N |
pad_sz = N*ceil (k/N) | |
for | i |
endfor endif | h = hb ./ ha |
f_r = f | |
endif endfunction!test | !b = [0.292893218813452 0.585786437626905 0.292893218813452] |
!a = [1 0 0.171572875253810] |
!assert | ( | f3 | , | |
[0:31] '* | 10, | |||
10 * | eps | |||
) |
!assert | ( | h | , | |
h2.' | , | |||
20 * | eps | |||
) |
!assert | ( | f2 | , | |
[0:15] * | 10, | |||
10 * | eps | |||
) |
!assert | ( | f | , | |
[0:15] '* | 10, | |||
10 * | eps | |||
) |
!assert | ( | w(1:16) | , | |
w2 | , | |||
20 * | eps | |||
) |
!assert | ( | h(1:16) | , | |
h2 | , | |||
20 * | eps | |||
) |
!assert | ( | h(2:16) | , | |
conj(h(32:-1:18)) | , | |||
20 * | eps | |||
) |
!assert | ( | h | , | |
freqz(b, a, w) | , | |||
10 * | eps | |||
) |
!assert | ( | abs(h(17)).^ | 2, | |
0. | 5, | |||
10 * | eps | |||
) |
!assert | ( | h(1) | , | |
1 | , | |||
10 * | eps | |||
) |
elseif | ( | nargin | = =1 |
) |
else freqz_plot | ( | f | , | |
h | ||||
) |
if | ( | nargout! | = 0 |
) |
if | ( | k | , | |
n/2 && | nargout = =0 | |||
) |
if | ( | nargin | = =4 |
) |
if | ( | ! | isscalarn | ) |
endif if | ( | isempty(n) | ) |
endif if | ( | isempty(a) | ) |
if | ( | ! | ischarregion)&&!isempty(region | ) |
!a = [1 0 0.171572875253810] |
!test !b = [0.292893218813452 0.585786437626905 0.292893218813452] |
a = a(:) |
b = b(:) |
f_r = f |
else N = 2*n |