Main Content

setExtractorParameters

Set nondefault parameter values for feature extractor object

Since R2021b

    Description

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

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

    example

    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 or a signalTimeFrequencyFeatureExtractor 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.

    Use the getExtractorParameters function to get a list of parameter names that you can use to extract featurename.

    Data Types: string | struct

    Tips

    • Use the getExtractorParameters function to get the list of available parameters to use when extracting the features that you enabled when creating the feature extractor object.

    Version History

    Introduced in R2021b