Hello Jonas,
I understand that you have a .CSV file from a logic analyzer that contains timestamp information and digital channel data. The issue you're facing is that the timestamp updates only when a channel changes, resulting in an irregular time interval between samples. You want to convert this irregular timestamp data to a fixed sample frequency of 200 MHz in MATLAB.
To convert the timestamp to a fixed sample frequency in MATLAB, you can use the "interp1()" function. This function performs interpolation to resample your data at the desired sample rate. Here's how you can do it:
- Read the .CSV file into MATLAB using the "readtable()" function. Assuming your timestamp is in the first column and the digital channels are in the subsequent columns, you can use the following code:
data = readtable('Test-online.csv', 'HeaderLines', 5);
channels = data{:, 2:end};
- Create a new time vector with the desired sample rate using the "linspace()" function. Assuming your data starts at time "t0" and ends at time "t1", you can generate the new time vector as follows:
newTime = linspace(t0, t1, round((t1 - t0) * newSampleRate));
- Use the "interp1()" function to resample the digital channels at the new time vector:
resampledChannels = interp1(timestamps, channels, newTime, 'nearest')
The 'nearest' option in "interp1()" performs nearest-neighbour interpolation, which is suitable for digital signals. To know more about the "interp1()" function, you can additionally refer to the MathWorks documentation in the link:
Now you have the resampled channels at a fixed 200 MHz sample rate in the "resampledChannels" variable. You can proceed to plot the data and perform spectrum analysis using MATLAB's plotting and signal processing functions.
I hope this helps!