MATLAB signal transformation

Source: Internet
Author: User

1. in digital signal processing, basic operations include generation sequence (unit step sequence, unit pulse sequence, sine sequence, exponential sequence, etc.), index sequence, and sine sequence, you only need to enter a simple formula.
The Unit Step and unit pulse sequence are easy to understand and understand using logical arrays,
If you need to generate delta (n-n0): x = (n = N0), the same step sequence Principle

2. column changes in the sequence
In the process of signal processing, it involves many signal processing, signal addition (multiplication), signal inversion, signal scale transformation, signal displacement, and signal cyclic shift, linear (cycle/circumference) convolution of signals, etc.
(1) addition (multiplication) of signals ):In principle, we need to maintain the equal length of the two segments, that is, we need to add zero in some places. At this time, the use of the find function of MATLAB can greatly reduce the amount of code.
N = min (N1), min (N2): max (N1), max (N2); % value range of Y
N = length (n); % length of Y
Y1 = zeros (1, N); y2 = Y1; % initialization of Y1, Y2
Y1 (find (n> = min (N1) & (n <= max (N1) = x1; % add 0 in Y1
Y2 (find (n> = min (N2) & (n <= max (N2) = x2; % add 0 in Y2

In this way, the sequence length is equal and only zero is added. You can add or multiply the values.

(2) shift of the sequence and reverse of the sequence: Do not change the range value. You only need to change the subscript.
(3) cyclic shift of Sequences: You cannot simply change the lower mark value. To obtain a circular sequence more conveniently, you can use Gallery ('circul', x) in MATLAB to generate length (x) * length (X) loop matrix,
For example, if X = [1 2 3], Gallery ('circul', x) = [1 2 3; 3 1 2; 3 2 1]
Code: (two methods are used)

The second is the gallery mentioned above. The first is to say that the X sequence is equal to copying twice to obtain a 1*(3 * length (x) vector, then we can get the result based on the shift Parameter m:


Function [y, N] = seq_xhyw (x, N1, m)
% M> 0 right
% M <0 left

% Approach 1
% X1 = x' * ones (1, 3 );
% X1 = x1 (:)';
%
% N = length (N1 );
% M = REM (m, n );
% Y = x1 (n + 1-m: N + N-M );
% N = N1;

% Approach 2
Y = Gallery ('circul', X );
M = Mod (M, length (N1 ));
Y = Y (m + 1 ,:);
N = N1;

(4) Periodic delay of Sequences: More than the sequence cycle and not greater than the sequence cycle (if less than the sequence cycle will cause overlap)


Function [y, N] = seq_zqyt (x, N1, t );
% T: the period of extension
% X: Sequence
% N1: The indice of Sequence
N = length (X );
If T> = N
Y = [x, zeros (1, T-N)];
Y = reshape (y '* ones (1, 3), 1, [])
N = N1 (1): N1 (1) + 3 * T-1
Else
Y = zeros (N, N );

For I = N:-1:1
Y (I, 1: I) = x (n-I + 1: End );
End

X_sum = sum (Y (end:-T: 1 ,:));
Y = x_sum (1: t );

Y = reshape (y '* ones (1, 3), 1, []);
N = N1 (1): N1 (1) + 3 * T-1;
End

(5) symmetric decomposition of sequences,Any function (signal) can be divided into an odd function and an even function. Simply use the formula for calculation (using the principle of addition mentioned above)


Function [Y1, Y2, N] = seq_oddeven (x1, N1)
% Y1: Even Singal
% Y2: Odd Signal

X2 = fliplr (X1 );
N2 =-fliplr (N1 );

N = min ([N1, N2]): max ([N1, N2]); % value range of Y
N = length (n); % length of Y
Y1 = zeros (1, N); y2 = Y1; % initialization of Y1, Y2
Y1 (find (n> = min (N1) & (n <= max (N1) = x1; % add 0 in Y2
Y2 (find (n> = min (N2) & (n <= max (N2) = x2; % add 0 in Y2

1 = 0.5*(Y1 + y2 );
Y2 = 0.5*(y1-y2 );

(6) scale transformation of Sequences: This has been pitted for a lot of time, but I still don't want to understand it, nor do I know that the code package does not contain all the situations. If you have more simple methods, please contact us!


Function [y, N] = seq_scachange (x, N1, m)
% M> 1 Sampling
% M <1 add 0

If M> 1
Logi = [Mod (N1, m) = 0];
[Num, IND] = find (Logi = 1 );
N = N1 (Ind (1)/m: N1 (Ind (1)/m + Length (Num)-1;
Y = x (IND );
Else
N = floor (N1 (1)/m): floor (N1 (end)/M );
K = length (N );

For I = 1: K
If Mod (N (I), 1/m) = 0
Y (I) = x (n (I) * m-min (N1) + 1 );
Else
Y (I) = 0;
End
End
End

(7) sequence Convolution:
Linear convolution is a built-in function of Matlab, Conv;
Cyclic convolution is the periodic delay of linear convolution (the previous periodic delay function can be used );
Circular Convolution is a sequence of periodic convolution to remove the primary value;
In this way, all three are connected. With Linear convolution, you can find the other two convolution.
(For convolution, the clever use of matrices may be unexpected ).

Contact Us

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.