Error using tsa function - Error using matlab.int​ernal.math​.interp1 Sample points must be unique.

While I've allready succesfully used the tsa function in the past, I stumbled upon the error as shown below, which I'm not able to get rid of. Intuitively I tried using the unique function to exclude possible duplicates in my TachoPulseTimes vector, but this didn't appear to solve the issue. I also tried swapping the sampling frequency argument fs for the corresponding time vector to make sure both the sampling time vector and tacho pulse times would start and end on equal time stamps, but with no luck. Any help would be much appriciated given I'm completly stuck at the moment.
load('TSA_DATA.mat')
AccData = upsample(tsaData.AccData,100);
fs = tsaData.SampFreq;
TachoPulseTimes = tsaData.TachoPulseTimes;
pprTacho = tsaData.pprTacho;
accDataTsaRaw = tsa(AccData,fs,TachoPulseTimes,"PulsesPerRotation",pprTacho);
Note: The accelerometer data was downsampled with a factor 100 to be able to include the data as attachment
Many thanks in advance,
Lars

9 comentarios

hi
pls provide the tsa function ....
There is a so-called 'unique()' function to make the sample points unique.
Hi Sam. As stated in my original question I tried removing possible duplicates in my TachoPulse-vector using the unique() function you specify, but without any succes.
Oops! I overlooked that in your description. Let me duplicate the error message first.
load('TSA_DATA.mat')
AccData = upsample(tsaData.AccData,100);
fs = tsaData.SampFreq
fs = 102400
TachoPulseTimes = tsaData.TachoPulseTimes;
pprTacho = tsaData.pprTacho;
accDataTsaRaw = tsa(AccData, fs, TachoPulseTimes, "PulsesPerRotation", pprTacho);
Error using matlab.internal.math.interp1
Sample points must be unique.

Error in interp1 (line 188)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);

Error in tsa (line 145)
temptsaM = interp1(tUp,xUp,tss,im,'extrap');
does the problem arrise only on a particular data set ? (if it had worked in the past , what has changed since ?)
& can you provide another data set that works ?
The data set it last worked on contained a smaller amount of samples, but measured on the same setup.
I also just noticed that when processing the old data I used an estimation of the sampling frequency 100kHz in comparison to the real sampling frequency of 102.4kHz as shown above. In addition the data was also processed for a different accelerometer, but I highly doubt this would be the culprit.
Let me first run again my old code adjusting these parameters, after which I will provide the old data set if needed.
Here is the old (working) data set which does not yield the error.
load('TSA_DATA_OLD.mat')
tsaData = struct with fields:
AccData: [-2.3163 0.6736 0.8462 0.7098 1.2671 1.0169 -2.3191 0.9164 0.6931 0.4014 0.2219 0.9967 1.4735 -0.1119 0.4298 2.3337 -1.2249 0.3470 ... ] (1x16501 double) SampFreq: 104200 TachoPulseTimes: [0 0.0072 0.0144 0.0214 0.0286 0.0357 0.0430 0.0499 0.0570 0.0642 0.0771 0.0906 0.0966 0.1037 0.1109 0.1182 0.1253 0.1324 0.1396 0.1468 ... ] (1x2168 single) pprTacho: 64
AccData = upsample(tsaData.AccData,100);
fs = tsaData.SampFreq;
TachoPulseTimes = tsaData.TachoPulseTimes;
pprTacho = tsaData.pprTacho;
accDataTsaRaw = tsa(AccData,fs,TachoPulseTimes,"PulsesPerRotation",pprTacho);
Warning: Truncating TP to the time range of X.

Iniciar sesión para comentar.

 Respuesta aceptada

hehe
there is only one difference between the two mat files , but it was enough to create the issue
>> load('TSA_DATA_OLD.mat') => AccData: [1×16501 double]
>> load('TSA_DATA.mat') => AccData: [1×254977 single]
so in the second case , don't forget to convert from single to double before calling tsa
AccData = upsample(double(tsaData.AccData),100)

3 comentarios

Thank you so much. I don't understand how I have overlooked this. I'm currently not in reach of my laptop, but will test as soon as possible and accept your answer.
As a last comment, I indeed remember exporting my larger data set in single precision format as opposed to double precision for my old data. This was due to the file size limit of Siemens Signature Acquisition.
maybe something worth to write as a comment in your code ...
all the best

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2023b

Preguntada:

el 18 de Abr. de 2024

Comentada:

el 19 de Abr. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by