The key thing to remember is that since nufft takes the sample points and frequency points as arguments, you have to remember how to manage their units and how they are defined relative to one another.
The formula for the classical DFT is
and typically we assume that each sample is defined as
where Ts is your sampling period and x() is your analog signal (note that I'm assuming MATLAB's 1-based indexing here, hence the -1 factors). Each represented DFT frequency corresponds to the sampled analog frequency of the spectrum so that X[k] corresponds to the spectral content at an analog frequency
.The generalized NUFFT equation is
In a call to nufft where you are not providing frequency points, the assumed points take the form of
Therefore, if you want results on a comparable scale, you have to scale your sample data to range from 0:(N-1):
timeDataUnif=[0:ts:1000*ts];
timeDataNunif=[0:ts:750*ts (750*ts+ts/2):ts/2:1000*ts];
nData1=length(timeDataUnif);
nData2=length(timeDataNunif);
sigDataUnif=sin(2.*pi.*f0.*timeDataUnif) +0.01.*rand(1,nData1);
sigDataUnif=sigDataUnif-sum(sigDataUnif)/nData1;
fSigData=fftshift(fft(sigDataUnif));
freqDataUnif=[0:nData1-1]./(nData1-1).*fs-fs/2;
freqDataNunif=[0:nData2-1]./(nData2-1).*(2.*fs)-fs;
sigDataNunif=2*sin(2.*pi.*f0.*timeDataNunif) +0.01.*rand(1,nData2);
nufSigData=fftshift(nufft(sigDataNunif,timeDataNunif/ts));
subplot(411),plot(timeDataUnif,'k.');hold on;
subplot(411),plot(timeDataNunif,'r.');title('uniform and nonuniform samples of 1 second time interval');xlabel('sample number');axis tight;grid on;grid minor;
subplot(412),plot(timeDataUnif,sigDataUnif,'k');hold on;title('different samples of the same function');
subplot(413),plot(freqDataUnif,abs(fSigData),'k');hold on;axis tight;V=axis;axis([V(1) V(2) -20 V(4)]); grid on;grid minor;
subplot(412),plot(timeDataNunif,sigDataNunif,'r--');hold on;title('FFT of the uniform samples');
subplot(414),plot(freqDataNunif,abs(nufSigData),'k');title('NUFFT of the nonuniform samples');grid on;grid minor;