Main Content

setExtractorParameters

Set nondefault values for feature extractor object

Since R2021b

    Description

    example

    setExtractorParameters(sFE,featurename,params) specifies the parameters used to extract featurename.

    setExtractorParameters(sFE,featurename) sets the parameters used to extract featurename to their default values.

    Examples

    collapse all

    Create a signalFrequencyFeatureExtractor object to extract the Welch power spectral density (PSD) estimate of a signal consisting of a 100 Hz sinusoid in additive N(0,1) white noise. The sample rate is 1 kHz and the signal has a duration of 5 seconds.

    fs = 1000;
    t = 0:1/fs:5-1/fs;
    x = cos(2*pi*100*t) + randn(size(t));
    
    sFE = signalFrequencyFeatureExtractor(SampleRate=fs,WelchPSD=true);

    For the PSD computation, set the OverlapLength to 25 samples and the FFTLength to 512 samples. Call the getExtractorParameters function on the object to view the PSD parameters.

    setExtractorParameters(sFE,"WelchPSD",OverlapLength=25,FFTLength=1024)
    params = getExtractorParameters(sFE,"WelchPSD")
    params = struct with fields:
              FFTLength: 1024
        FrequencyVector: []
          OverlapLength: 25
                 Window: []
    
    

    Use the extract function to extract the Welch's PSD estimate of the signal. Plot the result.

    feature = extract(sFE,x);
    
    fvec = linspace(0,fs/2,length(feature));
    plot(fvec,pow2db(abs(feature)))
    
    xlabel("Frequency (Hz)")
    ylabel("PSD (dB/Hz)")
    grid

    Input Arguments

    collapse all

    Feature extractor object, specified as a signalFrequencyFeatureExtractor object.

    Extracted feature, specified as a string scalar or a character vector.

    Data Types: char | string

    Parameters used to extract featurename, specified as name-value arguments or a structure.

    Data Types: string | struct

    Extended Capabilities

    Version History

    Introduced in R2021b

    expand all