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.
Kshitij Singh answered .
2025-11-20
% 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)