DFT (FFT) of Non Uniformly Sampled Signal
I am trying to perform an FFT of a non-uniformly sample signal. My input comes from Simulink and PLECS which uses variable-time solver.


Assuming that the first column in the data provided is your time variable ($t$) in units of seconds, the variable-time solver introduces a very small jitter.

(All code in Octave)

x = csvread("somefile.csv");
time_variable = x(3:end); %Skipping the first few samples as the solver settles.
plot(diff(time_variable)); %Ideally, this should return a flat plot at the sampling period, but that is not what we have here.


This results in:



Where you are sampling with at least a sampling period of something like $Ts \approx 1.68e-07$ extending to $Ts \approx 7.65e-07$.

The period of a 300Hz sinusoid that you are interested in is something like $0.00333 \ldots$ and the worst case scenario given above introduces an uncertainty of $\approx 0.022 \%$. That is per-cent.

Now, I am not sure which waveforms you are trying to obtain the spectrum of, but the second one is the one with the most discontinuities (the control signal?) and its spectrum looks like:

Fs = 1/7.6587e-07;
NFFT = 512;
FreqVec = Fs.*(0:(NFFT-1))./(NFFT-1);
semilogy(abs(fft(x(3:end,2),NFFT));
xlabel("Frequency (Hz)");ylabel("Amplitude");grid on;




Where as you can see, I have used the Sampling Frequency ($Fs$) of the worst case scenario, again, assuming that the first column contains the time variable in seconds.

Hope this helps.