spectralCentroid uses a window internally to compute the STFT of the signal. The default window length is 30 milliseconds, which is longer than your input signal, which explains the error.
You should set a shorter window, for example:
c = spectralCentroid(x,1e6,'Window',hann(1024),'OverlapLength',512);
Note that spectralCentroid was designed with audio signals in mind, so it might not be suitable for your needs. Consider using the function meanfreq instead.