# 6.1 Signal Processing Toolbox Changes

## 2.08 to 3.0a

New Functions:

Filter Design

remezord - Minimum order estimate needed to design a multiple band linear phase, equiripple FIR filter. remezord works for type I and type II linear phase filters only; that is, filters with even symmetric impulse response. remezord doesn't work for Hilbert transformers or differentiators.

firls - Linear phase FIR filter design which approximates a general piecewise linear desired function with transition bands; the integrated squared error is minimized (hence the name FIR Least Squares). firls has the same calling sequence as remez.

besselap, besself - Support for analog Bessel filters now provided to the 25th order. besselap finds the poles and zeros of an analog lowpass Bessel filter of specified order. besself finds a lowpass, highpass, bandpass, or bandstop Bessel filter. besselap is called in the same manner as the buttap, cheb1ap, cheb2ap, and ellipap functions; besself is called in the same manner as the butter, cheby1, cheby2, and ellip functions with the 's' option. There is no order selection routine similar to buttord, chep1ord, etc., for Bessel filters.

Filter Transformation

ss2sos, zp2sos - State-space or zero-pole-gain form to second order sections form. Pair the pole-zero pairs into second-order sections, order the sections, and multiplicatively scale them, to reduce noise gain and overflow in some fixed-point implementations.

sos2ss, sos2tf, sos2zp - Second order sections form to state-space, transfer-function, or zero-pole-gain form.

impinvar - Impulse invariance. Discretize an analog filter by sampling its impulse response.

tf2zp, zp2tf, ss2tf - Additional conversion functions.

poly2rc, rc2poly - Reflection coefficients of discrete lattice structure from filter coefficients, and vice versa.

Impulse Response

impz - Impulse response of a discrete-time system.

System Identification

lpc - Autocorrelation method to compute Linear Prediction Coefficients (AR modeling) for speech processing and data compression.

levinson - Levinson-Durbin recursion (called by lpc).

stmcb - Steiglitz-McBride iteration for parametric signal modeling (ARMA) for speech processing and data compression.

Special Functions

diric - Dirichlet or periodic sinc function of a given order on a matrix of values.

sinc - Sinc or sin(pi*x)/(pi*x) mathematical function on a matrix of values.

Multirate Signal Processing

resample - Resample a sequence, sampled at rate Fs, at the new rate Fs*p/q where p and q are integers.

intfilt - FIR filter design for use in interpolation.

One-Dimensional Median Filtering

medfilt1 - Median filter a vector or the columns of a matrix.

One-Dimensional Discrete Cosine Transform

dct, idct - Discrete cosine transform and the inverse discrete cosine transform of a vector, or of the columns of a matrix.

Communications Functions

modulate - AM DSB-SC (amplitude modulation, double side-band, suppressed carrier), AM DSB-TC (AM DSB-transmitted carrier), AM SSB (AM single side-band), FM (frequency modulation), PM (phase modulation), PWM (pulse width modulation), PTM (pulse time modulation) or QAM (quadrature amplitude modulation) given a message signal, carrier frequency, and sampling frequency.

demod - Demodulation. Same modulation types as the modulate function.

vco - Voltage Controlled Oscillator. Performs FM modulation.

New Spectral Analysis Suite

These functions use Welch's method of power spectrum estimation to give the results of the spectrum function in smaller pieces. They plot results by default, and use a specified window, overlap rate, FFT length, sampling frequency, and detrending option. psd and csd also optionally compute and plot confidence intervals.

psd - Power Spectral Density

csd - Cross Spectral Density

tfe - Transfer Function Estimate

cohere - Coherence Function Estimate

Plotting Functions

strips - Plot a signal in strips of specified length in the same axes, or plot the columns of a matrix in strips.

zplane - Plot poles and zeros in the complex plane with the unit circle as reference.
Enhancements and Improvements:

Filter Analysis

freqz - freqz now uses default values if the parameters are unspecified: denominator coefficient vector defaults to a = 1, and the number of frequency points n defaults to 512. Takes an additional sampling frequency parameter Fs. Plots log magnitude and phase in figure window if no output parameters are present.

freqs - freqs now finds a frequency vector, instead of requiring one as input. Defaults to n = 200 points and allows you to specify either the number of points or a frequency vector. Plots log magnitude and phase in figure window if no output parameters are present.

grpdelay - grpdelay now uses default values if the parameters are unspecified: denominator coefficient vector defaults to a = 1, and the number of frequency points n defaults to 512. Takes an additional sampling frequency parameter Fs. Allows you to specify a vector of frequencies instead of just a number. Plots the group delay in figure window if no output parameters are present.

Chirp Z-Transform

czt - Compute the z-transform of a vector (or the columns of a matrix) on a spiral or "chirp" contour in the z-plane. (See example in Signal Processing Toolbox User's Guide.)

Filter Design

remez - The remez function now works in a more general way. The basic calling sequence is the same:

h = remez(n,f,m,w,'options')

The magnitude vector m no longer needs to be specified in pairs of equivalent numbers. If the elements in a pair in the magnitude vector differ, remez approximates the line segment between the two elements. Thus the desired function is piecewise linear, with

transition bands. See the new firls function; remez and firls are almost identical functions, except that remez minimizes the maximum error, and firls minimizes the integrated squared error, between the desired magnitude and the filter's magnitude response.

Note: If you design differentiators with remez, you now need to use a different calling sequence.

butter, cheby1, cheby2, ellip - These functions now design analog filters as well as digital. To get an analog filter, use the 's' option as an additional input parameter.

Parametric Modeling

invfreqz, invfreqs - New algorithms guarantee stability and solve the problem of minimizing |H-B/A|, instead of the related but different problem of minimizing |HA-B|.

Spectral Estimation

spectrum - Accepts new options, including window function, sampling rate, and confidence level. Plots the power spectrum in a figure window if no output parameters are requested. If nfft is even, the length of the PSD estimate is now nfft/2+1 (instead of nfft/2) to include DC through Nyquist frequency terms.

Note: - The new definition of nfft may necessitate change to existing M-files.

spectrum no longer has an entry in the Signal Processing Toolbox User's Guide because it is superseded by the new functions psd, csd, cohere, and tfe.

specplot - This function will not be present in future versions of the Signal Processing Toolbox, because spectrum now handles plots.

Time-Frequency Analysis

specgram - The length of the window and the FFT length have been decoupled. Takes new options including window function and sampling frequency. Returns time and frequency vectors optionally. Plots the log of the spectrogram as an image in a figure window if no output parameters are requested. (See example in Signal Processing Toolbox User's Guide.)

Waveform Generation

sawtooth - sawtooth now takes an additional parameter, which allows you to "skew" the waveform so that the peak is moved to an arbitrary location in the interval [0,2*pi]. For example, you can now create triangle waves.

Two-Dimensional Signal Processing Functions

filter2 and conv2 have been enhanced to accept an optional third argument that specifies the size of the resulting matrix.

Y = filter2(B,X,'shape')

C = conv2(A,B,'shape')

For filter2, this 'shape' parameter can be:

'same' - Return the central part of the convolution that is the same size as X. This is the default.

'valid' - Return only those parts of the convolution that are computed without the zero-padded edges, size(Y) < size(X).

'full' - Return the full 2-D convolution, size(Y) > size(X).

For conv2, this 'shape' parameter is:

'same' - Return the central part of the convolution that is the same size as A.

'valid' - Return only those parts of the convolution that are computed without the zero-padded edges, size(C) = [ma-mb+1,na-nb+1] when size(A) > size(B).

'full' - Return the full 2-D convolution. This is the default.

conv2 is fastest when size(A) > size(B).
Bug Fixes:

A bug has been fixed in the buttord, chep1ord, cheb2ord, and ellipord functions. This bug was causing these functions to overestimate the orders for some bandpass and bandstop filters.

The xcorr function returned the correlation vector in backward order in versions that worked with MATLAB 3.5. This problem has been fixed.

The MEX-file version of remez (called remezf.mex) was limited to designing filters of order less than 128 and with fewer than 10 bands. Both of these limitations have been removed.

## 3.0a to 3.0b

Bug Fixes:

fftfilt - new choices for N and internal block length parameter, if N is unspecified. Avoids horrible inefficiencies possible when using the default N = 512.

filtdemo - to work on monochrome monitors.

filtfilt - different algorithm for filter initial conditions, avoids DC-offset problems of original 3.0 version.

intfilt - fix help.

lpc - fix help.

prony - handle case where not enough data.

remez - restore version 2.0 feature of zero-length bands.

ss2zp - index into scalar with ones to build matrix for Convex.

tf2zp - index into scalar with ones to build matrix for Convex.

zp2sos - fix help.

zplane - fix scalar and matrix cases.
Compatibility

Due to changes in remez and spectrum code, they are not fully downward compatible.

remez - The remez function now works in a more general way. The basic calling sequence is the same:

h = remez(n,f,m,w,'options')

The magnitude vector m no longer needs to be specified in pairs of equivalent numbers. If the elements in a pair in the magnitude vector differ, remez approximates the line segment between the two elements. Thus the desired function is piecewise linear, with transition bands. See the new firls function; remez and firls are almost identical functions, except that remez minimizes the maximum error, and firls minimizes the integrated squared error, between the desired magnitude and the filter's magnitude response.

Note: If you design differentiators with remez, you now need to use a different calling sequence.

spectrum - Accepts new options, including window function, sampling rate, and confidence level. Plots the power spectrum in a figure window if no output parameters are requested. If nfft is even, the length of the PSD estimate is now nfft/2+1 (instead of nfft/2) to include DC through Nyquist frequency terms.

Note: The new definition of nfft may necessitate change to existing M-files.

(c) Copyright 1994 by The MathWorks, Inc.