Question
I am using the spectrum.welch objects, and the documentation is not clear on how to specify the FFT length. There is some mention for using "User-Defined" and the dspopts object, but there are not any examples.
Related Questions
Expert Answer
Kshitij Singh
PhD Expert
Answered Nov 20, 2025
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
The documentation on setting the FFT length for the Spectrum objects is missing from the Signal Processing Toolbox manual.
To work around this issue, use the following code as an example for changing the FFT length for the Spectrum objects:
% Sample test data to perform the Welch method on: t=0:0.001:2*pi; x=sin(t); % Initialize the Spectrum and Options objects Hs=spectrum.welch; Hopts=dspopts.spectrum; % Change the options to use user-defined FFT length and Sampling Frequency set(Hs,'FFTLength','UserDefined'); set(Hopts,'NFFT',512); set(Hopts,'Fs',1000); % Display the results psd(Hs,x,Hopts)
Have a different question? Ask here