MATLAB: Index exceeds matrix dimensions error

exceeds matrix dimension errorindex

hi i was running this simple code,but i got this error,any idea how to fix it?
L = 140; % Length of signal
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
YY = fft(rawdata,NFFT)/L;
((((((((((Index exceeds matrix dimensions.))))))))
Error in Untitled2 (line 11)
YY = fft(rawdata,NFFT)/L;

Best Answer

How can you take 256 samples from an array with 140 samples? Maybe you need to pad it with zeros or something
newArray = [oldArray, zeros(1, NFFT - length(oldArray))];