Unit pulse sequence M file:
Function [x, N] = impseq (N0, N1, N2)
If (N0 <N1) | (N0> N2) | (N1> N2 ))
Error ('parameter must meet N1 <= N0 <= n2 ')
End
N = [N1: N2];
X = [(n-n0) = 0];
Call example:
[X, N] = impseq (2, 0, 5); % indicates that there are 6 vertices starting from 0, and the second vertex is 1.
Stem (n, x );
M file of unit step sequence:
Function [x, N] = stepseq (N0, N1, N2)
If (N0 <N1) | (N0> N2) | (N1> N2 ))
Error ('parameter must meet N1 <= N0 <= n2 ')
End
N = [N1: N2];
X = [(n-n0)> = 0];
Call:
[X, N] = stepseq (2, 0, 5 );
Stem (n, x );
In addition, I found the following error during the test: cannot find an exact (case-sensitive) match .... It seems that the case is different.
Change the file name (including. m) and function name to lowercase.
In Matlab, y = Conv (x, h) can be used to calculate convolution of two finite-length sequences. This function does not know the location information. By default, the X and H position vectors start from scratch. It can be expanded as needed.
Note here that the MATLAB default sequence starts from scratch, that is, 0: N-1. However, the subscript of the variable (the sequence number in the brackets) starts from 1, that is, 1: N.
The length range of the convolution output sequence is n = 0: length (x) + Length (y)-1.
When it comes to Convolution, the related functions are also convolution forms. For example, the cross-correlation between x and y is represented as convolution of Y (M) and X (-m, the auto-correlation of X is the convolution of X (M) and X (-m.
Note that the related functions also change with N. If there is a peak value between x and y at N0, it means y and X are similar after N0 shift.
The LTI system can be described by difference equations. However, the difference equations do not necessarily describe the LTI system and must meet the so-called relaxation conditions.
MATLAB can solve the difference equation by using Y = filter (B, A, X. B is the coefficient vector of X, A is the coefficient vector of Y, and X is the input sequence.
In addition, [h, N] = impz (B, A, n) can be used to solve H (n ).
Discrete Signals and Systems in the time domain