Tag Archives: The signal processing

The usage of Matlab function downsample

(I) Downsample
Reduce the sampling rate by an integer multiple

    syntax
    y =downsample (x, n)
    y =downsample (x, n, phase) y =downsample (x, n) reduces the sampling rate of x by retaining the first sample and then the NTH sample after the first sample. If x is a matrix, the function treats each column as a separate sequence. Y = Downsample (x, n, phase) specifies the number of samples for the sampling sequence under offset. Example 1:
    reduces the sampling rate of the sequence by a factor of 3. x = [1 2 3 4 5 6 7 8 9 10];
    y =downsample (x, 3)
    y = 1×4 1 4 7 10 example 2: reduce the sampling rate of the sequence by 3 times and increase the phase offset by 2. That is to offset two Numbers backward from the first number for downsampling y =downsample (x, 3, 2)
    y = 1×3 3 6 9
    x1 = [1 2 3 4 5 6 7 8 9];
    y =downsample(x1,3,1) y = 2 5 8
    example 3:
    reduces the sampling rate of the matrix by 3 times. X = [1 2 3;
    4 5 6;
    7 8 9;
    10, 11 12];
    y =downsample (x, 3)
    y = 2×3 12 3
    10 11 12 input parameters
    x — input array
    vector | matrix
    input array, specified as a vector or matrix. If x is a matrix, the function treats the columns as independent channels. Example: Cosine (PI/4 * (0:15 9)) + RANDn (1,160) specifies the sine curve plus the White Gaussian noise. Example: cos (PI./ [4; 2] * (0:15 9)) ‘+ randn (160,2) specifies a two-channel sine wave. Data type: single | double
    complex number support: is
    n – down sampling coefficient
    positive integer
    under sampling factor, specified as a positive integer. Data type: single | double
    phase – offset
    (default) | positive integer
    offset, specified as a positive integer between 0 and n-1. Data type: single | double output parameter
    y – down sampling array
    vector | matrix
    down sampling array, returned as a vector or matrix.

Problem solving: Pandas: keyerror: [ ] not in index

After data cleaning with packages like Numpy and Pandas, the corresponding columns in dataframe will be fed into models such as neural network or SVM as features or labels for model training. During this process, errors as shown in the question are likely to be encountered, such as:

X=data[features]
Y=data['6A']

The error was reported as follows:

was modified as follows:

X=data.iloc[:,1:21