| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Signal Processing Toolbox |
| Contents | Index |
| Learn more about Signal Processing Toolbox |
In this example, we construct a PSD estimate of a signal using Welch's overlapped segment method. To run the example, copy and paste the following code at the MATLAB command prompt.
Fs=10000; %sampling frequency t=0:(1/Fs):1; %one second time vector y=0.4*cos(2*pi*2000*t)+0.2*sin(2*pi*1000*t)+randn(size(t));
Next create a default Welch spectrum object.
h = spectrum.welch;
Entering h at the command prompt shows the default settings for the Welch spectrum object.
h =
EstimationMethod: 'Welch'
SegmentLength: 64
OverlapPercent: 50
WindowName: 'Hamming'
SamplingFlag: 'symmetric'If you want to specify parameters instead of using default values, you can use syntax like the following:
h=spectrum.welch('kaiser',128,50);The code creates a Welch spectrum object using a Kaiser window (see kaiser). We have set the segment length equal to 128 with an overlap percentage of 50. The Kaiser window has an additional parameter, beta, which governs the tradeoff between the width of the main lobe and level of energy in the sidelobes. Larger values of beta decrease the height of the sidelobes at the expense of widening the main lobe. You can specify additional parameters for a chosen window by passing them to the spectrum object in a cell array. For example,
h=spectrum.welch({'Kaiser',0.2},128,50)
h =
EstimationMethod: 'Welch'
SegmentLength: 128
OverlapPercent: 50
WindowName: 'Kaiser'
Beta: 0.2000For additional information on changing the property values of spectrum objects, see Changing Spectral Analysis Object Property Values for more information.
![]() | Introduction | Producing a PSD Estimate | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |