Main Content

freqz2

2-D frequency response

Description

[H,fx,fy] = freqz2(h) returns the 64-by-64 frequency response H of the 2-D FIR filter h. h must be in the form of a correlation kernel. freqz2 also returns the frequency vectors fx and fy as normalized frequencies in the range -1.0 to 1.0, where 1.0 corresponds to half the sampling frequency, or π radians.

example

[H,fx,fy] = freqz2(h,[nx,ny]) returns the ny-by-nx frequency response H of 2-D FIR filter h.

You can also specify nx and ny as two separate arguments: [H,fx,fy] = freqz2(h,nx,ny).

[H,fx,fy] = freqz2(h,[nx,ny],[dx,dy]) uses [dx,dy] to override the intersample spacing in h. You can also specify a scalar to use the same spacing in both the x and y dimensions.

H = freqz2(h,fx,fy) returns the frequency response for the 2-D FIR filter h at the specified frequency values in fx and fy. These frequency values must be in the range -1.0 to 1.0, where 1.0 corresponds to half the sampling frequency, or π radians.

freqz2(___) displays a mesh plot of the 2-D magnitude frequency response when no output arguments are specified.

Examples

collapse all

This example shows how to create a two-dimensional filter using fwind1 and how to view the filter's frequency response using freqz2.

Create an ideal frequency response.

Hd = zeros(16,16);
Hd(5:12,5:12) = 1;
Hd(7:10,7:10) = 0;

Create a 1-D window. This example uses a Bartlett window of length 16.

w = [0:2:16 16:-2:0]/16;

Create the 16-by-16 filter using fwind1 and the 1-D window. This filter gives the closest match to the ideal frequency response.

h = fwind1(Hd,w);

Display the actual frequency response of the filter.

colormap(parula(64))
freqz2(h,[32 32]);
axis ([-1 1 -1 1 0 1])

Figure contains an axes object. The axes object with xlabel F indexOf x baseline F_x, ylabel F indexOf y baseline F_y contains an object of type surface.

Input Arguments

collapse all

2-D FIR filter in the form of a correlation kernel, specified as a numeric matrix.

Number of points in the frequency response, specified as a positive integer or a 2-element vector of positive integers of the form [nx ny]. If you specify a positive integer, then freqz2 uses that number of points for both nx and ny.

Sample spacing, specified as a numeric scalar or a 2-element numeric vector of the form [dx dy]. dx determines the spacing for the x dimension and dy determines the spacing for the y dimension. If you specify a scalar, then freqz2 uses the value to determine the intersample spacing in both dimensions. The default spacing of 0.5 corresponds to a sampling frequency of 2.0.

Changing dx and dy has the effect of changing the spread of values in fx and fy. For example, setting dx to 0.25 instead of 0.5 causes the values in fx to range from -2.0 to 2.0 instead of -1.0 to 1.0. Setting dy to 1.0 instead of 0.5 causes fy to range from -0.5 to 0.5 instead of -1.0 to 1.0.

Frequency vectors, specified as numeric vectors.

Data Types: double

Output Arguments

collapse all

Frequency response, returned as a numeric array.

Frequency vector, returned as a numeric vector.

Data Types: double

Frequency vector, returned as a numeric vector.

Version History

Introduced before R2006a

See Also

(Signal Processing Toolbox)