How can I resample nonuniform data with sample and hold method?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone. I am new to resampling, and am getting a little lost while trying to implement the sample and hold method.
I have a matrix of 4 columns, and varying number of rows of data (and the gaps are filled by NaNs).
eg:R= [1 2 3 4 5; 1 2 NaN NaN 6; 1 2 NaN NaN 9; NaN 3 NaN NaN 5; NaN 4 NaN NaN NaN];
I have a second matrix of time series, having same structure as the above matrix. Each non-NaN cell in R has a corresponding timestamp.
I want to upsample R, such that all the columns have 100 entries, but I do not want to interpolate between values. What I want to do is use the 'nearest' function in interp1 or n=0 in resample, but not sure how to do it with this data structure. The attempts I made either give me an error of 'not enough inputs', or give me a resampled vector with extra zeros in it. I am not sure how to do this.
Basically, let's say my timestamps start at -1 s and ends at 20 s. For every point in time that there is not recorded value, I want it to take the value of the previous closest value, until it comes to the next value.
eg:(showing just one column here):
time=[-1 2 3 4 6 8 10 12 14 19]
R=[1 4 4 6 1 3 2 9 32 16];
What_I_want=[1 1 1 4 4 6 6 1 1 3 3 2 2 9 9 32 32 32 32 32 16 16];%so there is values for -1s to 20s, my fs here is 1Hz, if I understand correctly.
Any and all help will be very helpful. I have tried to explain as well as I could. I am pretty new to this. If any further information will be useful, please let me know. I realize I have been staring at my data for so long, that I may take some inherent features for granted. Hope people can understand my query.
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!