Generate a square wave
Clear
T = 0: 0. 0: 10;
Subplot (4, 1, 1)
F1 = square (t); % generates a square wave signal with a cycle of 2 pi
Plot (T, F1)
Axis ([1.2,-1.2,])
Subplot (4, 1, 2)
F2 = square (T, 30); % generates a square wave signal with a cycle of 2 PI and a duty cycle of 30%
Plot (T, F2)
Axis ([1.2,-1.2,])
Subplot (4, 1, 3)
F3 = square (2 * pI * t); % generates a square wave signal with a cycle of 1
Plot (T, F3)
Axis ([1.2,-1.2,])
Subplot (4, 1, 4)
F4 = square (2 * pI * t, 80); % generate a rectangular pulse signal with a cycle of 1 and A duty cycle of 80%
Plot (T, F4)
Axis ([1.2,-1.2,])
Generate a triangle wave and a jagged Wave
Clear
T = 0: 0. 0: 15;
Subplot (3, 1, 1)
F1 = sawtooth (t );
Plot (T, F1)
Axis ([1.2,-1.2,])
Subplot (3, 1, 2)
F1 = sawtooth (pI * t );
Plot (T, F1)
Axis ([1.2,-1.2,])
Subplot (3, 1, 3)
F1 = sawtooth (2 * pI * t, 0.5 );
Plot (T, F1)
Axis ([1.2,-1.2,])
Angle-Phase Angle
Usage
P = angle (z)
The function returns the phase angle P of vector z, in radians. If element vector or array Z is a plural 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 zero point Z, pole P, and gain K of the nth order low-pass analog besself filter. Where n equal to 25, p length is N, K is a scalar, and Z is an empty matrix.
Transfer Function:
Buttap-Butterworth low-pass analog filter
Usage
[Z, P, K] = buttap (N)
The function returns the zero point Z, pole P, and gain K of the n-order low-pass simulation Butterworth filter. The length of P is N, K is a scalar, and Z is an empty matrix.
Cheb1ap-chbixuefu 1 low-pass analog filter
Usage
[Z, P, K] = cheb1ap (n, RP)
The function returns the zero point Z, pole P, and gain K of the n-order slbievet 1 low-pass filter. The length of P is N, K is a scalar, and Z is an empty matrix. RP specifies the allowable Ripple type (unit: DB) on the pass belt ).
Cheb2ap-chbixuefu 2 low-pass analog filter
Usage
[Z, P, K] = cheb2ap (n, RS)
The function returns the zero point Z, pole P, and gain K of the n-order slbixuefu 2 low-pass analog filter. The length of Z and P is N. If n is an odd number, the length of Z is n-1, and K is a scalar. RS specifies the allowable Ripple type (unit: DB) on the stopband)
Time Domain Analysis
Conv-computing convolution
W = Conv (u, v)
Function compute convolution of two signal vectors u and v. Where u is m and V is N, the return W is (m + n + 1 ).
Cov-calculates Covariance
1. r = Cov (X)
Returns the covariance matrix R of the signal X. X can be a vector or matrix. When X is a vector, Cov (x) returns a scalar R containing variance. When X is a matrix, Cov (x) returns the covariance matrix.
2. r = Cov (x, y)
Returns the covariance between x and y.
Generate a random matrix and calculate the covariance matrix of the random matrix X.
FFT/IFFT-Fast Fourier transformation/Inverse Transformation
1. Y = FFT (X)/y = IFFT (X)
The function performs fast Fourier transformation/inverse transformation on X based on the algorithm of base 2. If X is a matrix, Fast Fourier transformation/inverse transformation is performed on each column of the Matrix. the return value is a matrix of the same size as X. If X is a multi-dimensional sequence, the first non-independent dimension is subjected to Fast Fourier transformation/inverse transformation.
2. Y = FFT (x, N)/y = IFFT (x, n)
The function performs N-point fast Fourier transformation/inverse transformation on X. When X is a vector, if X length is less than N, X is first supplemented with zero to make its length N; if x length is greater than N, then the X is cut to make its length N, and finally a vector y with the length N is obtained. When X is a matrix, each column of the Matrix is adjusted using the same method, and then each column of the Matrix is subjected to Fast Fourier transformation/inverse transformation, finally, a matrix Y of N rows is obtained.
3. Y = FFT (x, N, dim)/y = IFFT (x, N, dim)
Dim is used to specify the dimensions of the fast Discrete Fourier transformation/inverse transformation.
The signal sig contains a sine signal and a noise signal, and implements a fast Discrete Fourier transformation. Obtain the original signal frequency component.
> T = 0: 0. 005;
> X = sin (2 * pI * 20 * t) + cos (2 * pI * 60 * t );
> Sig = x + rand (1, length (t ));
> Subplot (1, 2 );
> Plot (SIG (1: 60 ));
> Title ('original signal fig ');
> Ftt_sig = FFT (SIG, 512); % perform a 512-point fast Discrete Fourier transformation for the SIG signal to zero
> P = ftt_sig. * conj (ftt_sig)/512; % calculate the power spectral density of the signal
> F = 1000 * ()/512; % set the frequency conversion range
> Subplot (1, 2 );
> Plot (F, ftt_sig () % to plot the power spectrum density distribution
> Title ('power spectral density fig ')
Fftfilt-FFT-based FIR Filter
Usage
Y = fftfilt (B, X)
The function uses the stacked addition method for FFT-based FIR filtering. Given the coefficient vector B, filter the input vector X.
Y = fftfilt (B, X, n)
The function uses the stacked addition method for FFT-based FIR filtering. Given the coefficient vector B, filter the input vector X. N is used to determine the length of the FFT.
Filtfilt-Zero-Phase Digital Filtering
Usage
Y = filtfilt (B, A, X)
The function performs forward and reverse processing on the input signal X to implement zero-phase digital filtering. B and A specify the coefficient of the passing function. X is the input signal. After the function filters x forward, the result is reversed.
Hilbert-Hilbert transformation
X = Hilbert (xr)
The function returns a complex sequence X with the same length by performing a Hilbert transformation on the real sequence XR. If XR is a matrix, each column of the XR matrix is transformed by Hilbert.
X = Hibert (XR, n)
The function performs the n-point Hilbert transformation of the real sequence XR and returns a complex sequence X of the same length. Perform zero or zero-removing Operations on XR to set its length to n.
Impinvar-convert the analog filter to a digital filter using the Impact Response invariant method
Usage
[BZ, AZ] = impinvar (B, A, FS)
While keeping the Impact Response unchanged, the function converts the molecular 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. FS is the sampling frequency of the analog filter. The default value is 1Hz.
[BZ, AZ] = impinvar (B, A, FS, Tol)
The method is the same as above. tol is the specified tol. A larger ToL is, the impinvar function is more likely to approach the pole. The default value is 0.001 of the pole value.
Residuez-Z Inverse Transformation
Usage
[R, P, K] = residuez (B,)
The function performs a Z Inverse Transformation on the rational Z function. B and A are the molecular polynomial coefficient vectors of rational Z functions and the denominator polynomial coefficient vectors. Returns the r as the left column vector, and P as the pole column vector. If the order of the molecular polynomial is greater than the order of the denominator polynomial, k is the direct term in the expansion.
Signal Generation
Ones-generate unit step signal
Signal = ones (1, N)
The function generates a set of N-point unit step signal with a length of N and a signal amplitude of 1.
Generates a unit step signal with a length of 5 and the signal amplitude is 1.
Signal = ones (1, 5)
Zeros-generate unit sampling signal
The signal = [1, zeros (1, N-1)] function generates a set of unit Sampling Signals signal.
1. Generate a set of unit Sampling Signals with a length of 5
Signal = [1, zeros (1, 5-1)]
2. Generate a unit sampling signal with a length of 5, which delays two cycles on the timeline.
X = zeros (1, 5) x (2) = 1
Sawtooth-generate sawtooth/triangular wave signals
1. The Sawtooth (t) function generates a sawtooth wave with a period of 2 pi for the time variable t, and the amplitude changes between + 1 and-1.
2. The Sawtooth (T, width) function generates a triangle wave on the time variable t. The width is the scale parameter of the value between 0 and 1, specifying the position of the peak of the sawtooth wave. The function is increased from-1 to + 1 in the range [0, width * 2 * Pi]. In [width * 2 * Pi, 1] The range is reduced from + 1 to-1.
When width is set to 1, positive and horizontal sawtooth waves are generated. When width is set to 0, negative and width = 0.5 are generated, symmetric and jagged waves are generated.
Square-generate a Square Wave Signal
1. x = square (t) function generates a square wave with a period of 2 PI and an amplitude of +-1 for the time variable t.
2. x = square (T, duty) function is a square wave with a specified period and an amplitude of +-1. Duty is the proportion of a region with positive signals in a period.
From: http://blog.csdn.net/gwh111/article/details/8667041
MATLAB Digital Signal Processing