Power Spectrum Estimates

Create the Block Diagram

Up until now, you have been dealing with signals in the time domain. The DSP System Toolbox™ product is also capable of working with signals in the frequency domain. You can use the software to perform fast Fourier transforms (FFTs), power spectrum analysis, short-time FFTs, and many other frequency-domain applications.

The power spectrum of a signal represents the contribution of every frequency of the spectrum to the power of the overall signal. It is useful because many signal processing applications, such as noise cancellation and system identification, are based on frequency-specific modifications of signals.

First, assemble and connect the blocks needed to calculate the power spectrum of your speech signal:

  1. Open a new Simulink® model.

  2. Add the following blocks to your model. Subsequent topics describe how to use these blocks.

    BlockLibrary

    Signal From Workspace

    Sources

    Buffer

    Signal Management / Buffers

    Periodogram

    Estimation / Power Spectrum Estimation

    Vector Scope

    Sinks

  3. Connect the blocks as shown in the next figure.

Once you have assembled the blocks needed to calculate the power spectrum of your speech signal, you can set the block parameters.

Set the Model Parameters

Now that you have assembled the blocks needed to calculate the power spectrum of your speech signal, you need to set the block parameters. These parameter values ensure that the model calculates the power spectrum of your signal accurately:

  1. If the model you created in Create the Block Diagram is not open on your desktop, you can open an equivalent model by typing

    ex_gstut9ex_gstut9

    at the MATLAB® command prompt.

  2. Load the speech signal into the MATLAB workspace by typing load mtlb at the MATLAB command prompt. This speech signal is a woman's voice saying "MATLAB."

  3. Use the Signal From Workspace block to import the speech signal from the MATLAB workspace into your Simulink model. Open the Signal From Workspace dialog box by double-clicking the block. Set the block parameters as follows:

    • Signal = mtlb

    • Sample time = 1/8000

    • Samples per frame = 80

    • Form output after final data value by = Setting to zero

    Once you are done setting these parameters, the Signal From Workspace dialog box should look similar to the figure below. Click OK to apply your changes.

    The DSP System Toolbox product is capable of frame-based processing. In other words, DSP System Toolbox blocks can process multiple samples of data at one time. This improves the computational speed of your model. In this case, by setting the Samples per frame parameter to 80, you are telling the Signal From Workspace block to output a frame that contains 80 signal samples at each simulation time step. Note that the sample period of the input signal is 1/8000 seconds. Also, after the block outputs the final signal value, all other outputs are zero.

  4. Use the Buffer block to buffer the input signal into frames that contain 128 samples. Open the Buffer dialog box by double-clicking the block. Set the block parameters as follows:

    • Output buffer size (per channel) = 128

    • Buffer overlap = 48

    • Initial conditions = 0

    • Treat Mx1 and unoriented sample-based signals as = One channel

    Once you are done setting these parameters, the Buffer dialog box should look similar to the figure below. Click OK to apply your changes.

    Based on these parameters, the first output frame contains 48 initial condition values followed by the first 80 samples from the first input frame. The second output frame contains the last 48 values from the previous frame followed by the second 80 samples from the second input frame, and so on. You are buffering your input signal into an output signal with 128 samples per frame to minimize the estimation noise added to your signal. Because 128 is a power of 2, this operation also enables the Periodogram block to perform an FFT on the signal.

  5. Use the Periodogram block to compute a nonparametric estimate of the power spectrum of the speech signal. Open the Periodogram dialog box by double-clicking the block and set the block parameters as follows:

    • Measurement = Power spectral density

    • Window = Hamming

    • Window sampling = Periodic

    • Select the Inherit FFT length from input dimensions check box.

    • Number of spectral averages = 2

    Once you are done setting these parameters, the Periodogram dialog box should look similar to the figure below. Click OK to apply your changes.

    Based on these parameters, the block applies a Hamming window periodically to the input speech signal and averages two spectra at one time. The length of the FFT is assumed to be 128, which is the number of samples per frame being output from the Buffer block.

  6. Use the Vector Scope block to view the power spectrum of the speech signal. Open the Vector Scope dialog box by double-clicking the block. Set the block parameters as follows:

    • Input domain = Frequency

    • Click the Axis Properties tab.

    • Clear the Inherit sample time from input check box.

    • Sample time of original time series = 1/8000

    • Y-axis label = Magnitude-squared, dB

    Once you are done setting these parameters, the Axis Properties pane of the Vector Scope dialog box should look similar to the figure below. As you can see by the Y-axis scaling parameter, the decibel amplitude is plotted in a vector scope window.

    Because you are buffering the input with a nonzero overlap, you have altered the sample time of the signal. As a result, you need to specify the sample time of the original time series. Otherwise, the overlapping buffer samples lead the block to believe that the sample time is shorter than it actually is.

After you have set the block parameter values, you can calculate and view the power spectrum of the speech signal.

View the Power Spectrum Estimates

In the previous topics, you created a power spectrum model and set its parameters. In this topic, you simulate the model and view the power spectrum of your speech signal:

  1. If the model you created in Set the Model Parameters is not open on your desktop, you can open an equivalent model by typing

    ex_gstut10ex_gstut10

    at the MATLAB command prompt.

  2. Set the configuration parameters. Open the Configuration Parameters dialog box by selecting Model Configuration Parameters from the Simulation menu. Select Solver from the menu on the left side of the dialog box, and set the parameters as follows:

    • Stop time = 0.5

    • Type = Fixed-step

    • Solver = Discrete (no continuous states)

  3. Apply these parameters and close the Configuration Parameters dialog box by clicking OK. These parameters are saved only when you save your model.

  4. If you have not already done so, load the speech signal into the MATLAB workspace by typing load mtlb.

  5. Run the model to open the Vector Scope window. The data is not immediately visible at the end of the simulation. To autoscale the y-axis to fit the data, in the Vector Scope window, right-click and choose Autoscale. The following figure shows the data displayed in the Vector Scope window.

During the simulation, the Vector Scope window displays a series of frames output from the Periodogram block. Each of these frames corresponds to a window of the original speech signal. The data in each frame represents the power spectrum, or contribution of every frequency to the power of the original speech signal, for a given window.

In the next section, Spectrograms, you use these power spectra to create a spectrogram of the speech signal.

Was this topic helpful?