# The common methods in digital signal processing

Source: Internet
Author: User
Tags scalar

Generate Square Wave

Clear
T=0:0.01:10;
Subplot (4,1,1)
F1=square (t); % square wave signal with 2PI cycle
Plot (T,F1)
Axis ([0,10,-1.2,1.2])
Subplot (4,1,2)
F2=square (t,30); 2pi square wave signal with a duty cycle of 30%
Plot (T,F2)
Axis ([0,10,-1.2,1.2])
Subplot (4,1,3)
F3=square (2*pi*t); % Square wave signal with 1 cycle
Plot (T,F3)
Axis ([0,10,-1.2,1.2])
Subplot (4,1,4)
F4=square (2*pi*t,80); A rectangular pulse signal with a period of 1 and a duty cycle of 80%
Plot (T,F4)
Axis ([0,10,-1.2,1.2])

Generate triangular wave, sawtooth wave

Clear
t=0:0.01:15;
Subplot (3,1,1)
F1=sawtooth (t);
Plot (T,F1)
Axis ([0,15,-1.2,1.2])
Subplot (3,1,2)
F1=sawtooth (pi*t);
Plot (T,F1)
Axis ([0,15,-1.2,1.2])
Subplot (3,1,3)
F1=sawtooth (2*pi*t,0.5);
Plot (T,F1)
Axis ([0,15,-1.2,1.2])

angle-phase angle to be obtained

Usage

P=angle (Z)

The function returns the phase angle p of the vector z, in radians, and if the element vector or array z is a complex number, the phase angle is between-PI and +pi.

Besselap-besself low-pass analog filter

Usage

[Z,p,k]=besselap (N)

The function returns the N-order low-pass analog besself filter's 0-point z, Pole P, and gain K. where n = 25, and the length of P is n,k, and z is an empty matrix.

Transfer function:

Buttap-butterworth low-pass analog filter

Usage

[Z,p,k]=buttap (N)

The function returns the N-order low-pass analog Butterworth filter's 0-point z, Pole P, and gain K. Where the length of P is n,k, and z is an empty matrix.

cheb1ap-Chebyshev 1 Low-pass analog filter

Usage

[Z,p,k]=cheb1ap (N,RP)

The function returns the 0 point Z, Pole P, and gain K of the N-order Chebyshev 1 Low-pass filter. Where the length of P is n,k, and z is an empty matrix. The RP specifies the allowable ripple type (in db) on the pass band.

cheb2ap-Chebyshev 2 Low-pass analog filter

Usage

[Z,p,k]=cheb2ap (N,rs)

The function returns the 0 point Z, Pole P, and gain K of the N-order Chebyshev 2 Low-pass analog filter. Where the length of z and P is n and if n is odd, the length of z is n-1,k to scalar. RS Specifies the allowable ripple type (in db) on the Resistance band

Time Domain Analysis

conv-Calculating convolution

W=conv (U,V)

The function calculates the convolution of the two signal vectors u and v. where u has a length of m,v of N, the computed result w length (m+n+1) is returned.

cov-Calculating covariance

1.r=cov (X)

The function returns the covariance matrix r of the signal x. X can be a vector or a matrix. When x is a vector, cov (x) returns a scalar R containing the variance. When x is a matrix, cov (x) returns the covariance matrix.

2.r=cov (x, y)

The function evaluates the covariance between the signal X and Y.

A random matrix is generated and then the covariance matrix of the random matrix X is computed.

fft/ifft-fast Fourier transform/Inverse transform

1.y=fft (x)/y=ifft (x)

The function follows the algorithm of base 2 for fast Fourier transform/inverse transformation of x. If x is a matrix, a fast Fourier transform/inverse transformation is performed on each column of the matrix, and the y is the same size matrix as x. If x is a multidimensional sequence, a fast Fourier transform/inverse transformation is performed on the first non-individual dimension.

2.y=fft (x,n)/y=ifft (x,n)

The function makes an n-point fast Fourier transform/inverse transformation on X. When x is a vector, if x is less than n, then the X is 0 to the length of n, and if x is longer than N, the x is clipped to the length n, and finally a vector y of length n is obtained. When x is a matrix, the same method is used to adjust each column of the matrix, then a fast Fourier transform/inverse transformation is performed on each column of the Matrix, and finally a matrix Y of n rows is obtained.

3.y=fft (X,n,dim)/y=ifft (X,n,dim)

As above, dim is used to specify the number of dimensions for fast discrete Fourier transform/inverse transformations.

The signal sig contains a sinusoidal signal and a noise signal, which is fast discrete Fourier transform. and find out the original signal frequency components.

>> t=0:0.005:1;
>> X=sin (2*pi*20*t) +cos (2*pi*60*t);
>> Sig=x+rand (1,length (t));
>> subplot (1,2,1);
>> plot (SIG (1:60));
>> title (' Original signal graph ');

>> Ftt_sig=fft (sig,512); % 512-point fast discrete Fourier transform with zero complement to the SIG signal
>> P=ftt_sig.*conj (FTT_SIG)/512; % for signal power spectral density
>> f=1000* (0:255)/512; % Set Frequency Transform range
>> subplot (1,2,2);
>> plot (F,ftt_sig (1:256))% plot power spectral density distribution map

>> title (' Power Spectral density graph ')

fftfilt-based on FFT amount FIR Filter

Usage

Y=fftfilt (b,x)

The function uses the superposition method to perform the FIR filter based on FFT. The input vector x is filtered by the given coefficient vector b.

Y=fftfilt (B,x,n)

The function uses the superposition method to perform the FIR filter based on FFT. The input vector x is filtered by the given coefficient vector b. n is used to determine the length of the FFT.

filtfilt-0 Phase Digital Filter

Usage

Y=filtfilt (b,a,x)

The function carries forward and reverse processing of the input signal X to achieve zero phase digital filtering. B and a specify the coefficients of the transfer function, and x is the input signal. The function makes a forward filter to X and then reverses the result.

hilbert-Hilbert transform

X=hilbert (XR)

The function will perform a Hilbert transformation of the real sequence XR, returning a complex sequence x of the same length. If the XR is a matrix, the Hilbert transform is performed on each column of the XR matrix.

X=hibert (Xr,n)

The function adds a real sequence XR to the N-point Hilbert transform, returning a complex sequence x of the same length. The XR is made up to 0 or zero to make its length n.

Impinvar-the analog filter into a digital filter with impact response invariance

Usage

[Bz,az]=impinvar (B,A,FS)

The function converts the numerator denominator B and a of the transfer function of the analog filter to the numerator denominator BZ and AZ of the transfer function of the digital filter, while maintaining the impact response unchanged. FS is the sampling frequency for the analog filter, which defaults to 1hz.

[Bz,az]=impinvar (B,a,fs,tol)

In the same way, Tol is the specified tolerance, the larger the Tol, the greater the likelihood of the Impinvar function approaching the pole, which defaults to 0.001 of the pole value.

Residuez-z Inverse transformation

Usage

[R,p,k]=residuez (B,a)

The function makes a Z-inverse transformation of the rational Z function. B and A are the molecular polynomial coefficient vectors and denominator polynomial coefficients vectors of the rational z-function respectively. The r is the left sequence vector, p is the pole column vector, and if the order of the molecular polynomial is greater than the order of the denominator polynomial, k is the direct term in the expanded type.

Signal generation

ones-Generating Unit step signal

Signal=ones (1,n)

The function produces a set of N-point unit step signal signal, the length is n, the signal amplitude is 1.

Generates a unit step signal of length 5 with a signal amplitude of 1.

Signal=ones (1,5)

zeros-Generating Unit sampling signal

The Signal=[1,zeros (1,n-1)] function produces a set of unit sampled signal signal.

1. Generate a set of 5 unit sampling signals

Signal=[1,zeros (1,5-1)]

2. Generate a unit sampling signal with a length of 5, which delays 2 cycles on the timeline.

X=zeros (1,5) x (2) =1

sawtooth-generating sawtooth/triangular wave signals

The 1.sawtooth (t) function produces a sawtooth wave with a period of 2pi for the time variable T, and the amplitude varies between +1 and 1.

The 2.sawtooth (t,width) function produces a triangular wave to the time variable t, and width is the scale parameter between 0 and 1, specifying the position where the crest of the Sawtooth wave appears. The function is increased from 1 to +1 in the [0,width*2*pi] interval and is reduced from +1 to 1 in the [width*2*pi,1] interval.

When Width=1, a positive sawtooth wave is produced, and when Width=0, a negative sawtooth wave is produced, and a symmetrical sawtooth wave is produced width=0.5.

Square-Raw Comparator signal

The 1.x=square (t) function has a period of 2pi for the time variable T and a square wave with a amplitude of +-1.

The 2.x=square (t,duty) function is a square wave that produces a specified period of time variable t, with a amplitude of +-1. The duty is the proportion of the area in which the signal is positive in one cycle.

The common methods in digital signal processing

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.