Interpolating linearly between many values in a vector

1 回表示 (過去 30 日間)
Mitch Hezel
Mitch Hezel 2019 年 8 月 14 日
編集済み: Stephen23 2019 年 8 月 16 日
I am using a sensor which updates time information at 1Hz, but samples data at 1kHz. Therefore I have a time array like so:
t_old =
if the collect was n seconds long. I would like 999 other time stamps in between the already existing ones. So the result ought to be
t_new =

回答 (2 件)

Adam Danz
Adam Danz 2019 年 8 月 14 日
編集済み: Adam Danz 2019 年 8 月 16 日
Set the 'resampleRate' to 1000 if you want [1,2] to become [1.001, 1.002, ... 2.999].
'timestamps' is your original vector.
resampleRate = 1000;
timestamps = 1:10; %must be a vector
timeStampsResampled = reshape((timestamps(:) + linspace(0,1-1/resampleRate,resampleRate)).',1,[]);

Stephen23
Stephen23 2019 年 8 月 16 日
編集済み: Stephen23 2019 年 8 月 16 日
>> t_old = 1:10; % times 1:N
>> rate = 1000; % 1 kHz
>> t_new = linspace(t_old(1),t_old(end),(numel(t_old)-1)*rate+1);

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by