interp1 question for resampling

7 ビュー (過去 30 日間)
Andra Topan
Andra Topan 2021 年 4 月 11 日
コメント済み: Star Strider 2021 年 4 月 12 日
I am trying to use interp1 to resample my data. I have the values of forces for different timeframe lengths. (eg. I have 4 trials, trial one has 36 frames, trial 2 has 43, trial 3 has 38, tria4 has 35). To compare them have a nice figure, I want to <<expand>> the number of frames to 100 for each of them (like it would be 1-100% of the timeframe).
I used resample in the beginning, but I get some noise in the beginning and the end of the signal.
dif_Fx = (resample(dif(1:motion_length,1),100,motion_length))
(motion_length is the number of frames and dif is my signal)
I tried to use interp1 as
dif_Fx = (interp1((dif(1:motion_length,1)),1:1:100));
dif_Fx is just the signal (dif), and the rest of the values, from motion_length+1 to 100 are NaN.
I have read again and again the documentation, but I can;t seem to understand how to modify it to get what I want.
Any help is much appreciated.

採用された回答

Star Strider
Star Strider 2021 年 4 月 11 日
To prevent the NaN results from being part of the interp1 output, specify an interpolation method and use the 'extrap' argument. See the function documentation for details.
  8 件のコメント
Andra Topan
Andra Topan 2021 年 4 月 12 日
Thank you so much! This was really helpful.
It woked with minor tweaks.
Star Strider
Star Strider 2021 年 4 月 12 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by