| 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 |
| On this page… |
|---|
After you have created a spectrum object, you can use the set method or dot notation to change any of its properties, except theEstimationMethod property. (Since EstimationMethod is the central property of a particular spectrum object, you cannot change it.) To change the window from Hamming (used in the Welch object) to Chebyshev, use dot notation as follows:
h.WindowName = 'Chebyshev'
h =
EstimationMethod: 'Welch'
SegmentLength: 66
OverlapPercent: 50
WindowName: 'Chebyshev'
SidelobeAtten: 100set(h,'WindowName','Chebyshev')
Chebyshev windows have a sidelobe attenuation parameter that automatically appears in the list of properties. To change a window parameter, you use a cell array containing the window name and parameter value, such as,
h = spectrum.welch({'Chebyshev',80})
h =
EstimationMethod: 'Welch'
SegmentLength: 64
OverlapPercent: 50
WindowName: 'Chebyshev'
SidelobeAtten: 80To see a list of all available window functions for the Welch spectral analysis object, enter the following at the MATLAB command prompt:
set(h,'windowname')
ans =
'Bartlett'
'Bartlett-Hanning'
'Blackman'
'Blackman-Harris'
'Bohman'
'Chebyshev'
'Flat Top'
'Gaussian'
'Hamming'
'Hann'
'Kaiser'
'Nuttall'
'Parzen'
'Rectangular'
'Taylor'
'Triangular'
'Tukey'
'User Defined'The Signal Processing Toolbox provides the most common window functions used in nonparametric spectral analysis. However, you also have the flexibility to use a user-defined window function as the next section demonstrates.
This section demonstrates how to construct a Welch PSD estimate with a user-defined window, a discrete prolate spheroidal sequence (see dpss). First, construct a Welch spectral analysis object with a user-defined window function using the following code:
h=spectrum.welch('user defined')
h =
EstimationMethod: 'Welch'
SegmentLength: 64
OverlapPercent: 50
WindowName: 'User Defined'
MATLABExpression: ''
Parameters: []To specify a discrete prolate spheroidal sequence as the window function, set the MATLABExpression property to 'dpss'. You use the syntax dpss(N,NW,1) to construct the window function. N is the SegmentLength property, NW represents the time half bandwidth product, and the scalar 1 indicates use of only the first discrete prolate spheroidal sequence.
set(h,'matlabexpression','dpss')
h =
EstimationMethod: 'Welch'
SegmentLength: 64
OverlapPercent: 50
WindowName: 'User Defined'
MATLABExpression: 'dpss'
Parameters: []Finally, use the Parameters property to supply required or optional input arguments for the window function defined by MATLABExpression. This example uses a time half bandwidth product of 2.5. You specify the length by the SegmentLength property. Because you are not constructing a multitaper spectral estimate, you use only the first discrete prolate spheroidal sequence.
set(h,'parameters',{2.5,1})
h
h =
EstimationMethod: 'Welch'
SegmentLength: 64
OverlapPercent: 50
WindowName: 'User Defined'
MATLABExpression: 'dpss'
Parameters: {[2.5000] [1]}MATLAB evaluates the user-defined window as dpss(64,2.5,1).
The following MATLAB code obtains the Welch PSD estimate of a signal with a user-defined window. Use the first discrete prolate spheroidal sequence of length 128 and a time half bandwidth product of 2.5 as the window function
Fs=10000; %sampling frequency
t=0:(1/Fs):1; %one second time vector
y=0.4*cos(2*pi*2000*t)+0.4*sin(2*pi*1000*t)+randn(size(t));
h=spectrum.welch('user defined');
set(h,'matlabexpression','dpss',...
'parameters',{2.5,1},'segmentlength',128);
Hs=psd(h,y,'Fs',Fs);
plot(Hs);

Another way to set properties for a particular estimation method is to use the options object associated with that method. For example, use the following syntax to create an options object from the spectrum object for use with the mean-square spectrum:
Hopts = msspectrumopts(h) % Create options object
Hopts =
NFFT: 'Nextpow2'
NormalizedFrequency: true
Fs: 'Normalized'
SpectrumType: 'Onesided'
CenterDC: falseYou can change any of the options properties using set, followed by the options object and property-value pairs, such as
set(Hopts,'Fs',48000)
To pass the options object to the first msspectrum in the filtered data, use
msspectrum(h,yw(:,1),Hopts)
Options objects that correspond to psd and pseudospectrum are psdopts and pseudospectrumopts, respectively.
![]() | Producing a PSD Estimate | Measuring Signal Power | ![]() |

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 |