MATLAB: The number of samples to overlap must be less than the length of the segments

digital signal processing

Can anyone correct this code and tell where I did wrong exactly ?
fs =16000;
t=0:1/fs:0.5;
signal=2*sin(2*pi*300*t);
noise=5*randn(1,length(signal));
input_speech=noise(1:8000)+signal(1:8000);
removal_sample=input_speech(1,6000:end);
RS=removal_sample(1:256);
t_min=0.075;
t_max=0.100;
[STFT,Freq,Time] =spectrogram(RS+1i*eps,window,window_length,NFFT,fs);

Best Answer

%@Walter sir already mentioned define Window length and lenght of fft, its works
fs =16000;
t=0:1/fs:0.5;
signal=2*sin(2*pi*300*t);
noise=5*randn(1,length(signal));
input_speech=noise(1:8000)+signal(1:8000);
removal_sample=input_speech(1,6000:end);
RS=removal_sample(1:256);
t_min=0.075;
t_max=0.100;
%Decide the FFT length
NFFT=1024; %For Example
[STFT,Freq,Time] =spectrogram(RS+1i*eps,window,length(window),NFFT,fs);