How to repeat data because of variables with two different timestamps?
1 回表示 (過去 30 日間)
古いコメントを表示
I have measured data with two different devices.
One device (Garmin device) measured data every second for about 20 minutes, so I have data with a 1207x1 format.
The other device (Cosmed device) measured data every 3 seconds (so 1, 4, 7, 10, etc.) also for about 20 minutes, so this results in a 470x1 format.
I want to compare variables measured from these devices, but for a reliable analysis I have to have the same time dimension (either per 1 or 3 seconds).
So...
Therefore, I want to repeat the data for 3 seconds three times, because this does not manipulate your data with interpolation or averaging (it's the best I can do I think in this situation).
What is the simplest way to achieve this?
3 件のコメント
Star Strider
2023 年 9 月 2 日
Not at all straightforward.
Torsten
2023 年 9 月 2 日
a = [1 2 3];
b = [1 5 8 2 9 12 7 5 16];
a3 = [];
for i = 1:numel(a)
a3 = [a3,a(i),a(i),a(i)];
end
a3
採用された回答
dpb
2023 年 9 月 2 日
Illustrate --
t=seconds(0:1:300).'; % one-second time series arbitrary length
tG=timetable(t,randn(size(t)),'VariableNames',{'Garmin'}); % create a 1-sec timetable
tC=timetable(t(1:3:end),randn(ceil(numel(t)/3),1),'VariableNames',{'Cosmed'}); % and another 3-sec
head(tC)
tC=retime(tC,'secondly','previous'); % convert the 3-sec to 1-sec by repeating sampled data
tGC=[tG tC]; % now put the two together
head(tGC)
With two files, you'll just read each and have the time vectors in them, I presume -- so read each and augment the shorter as needed...
5 件のコメント
dpb
2023 年 9 月 3 日
Yeah, retime is very flexible but it does require using a timetable to get access to it; it's understandable why is so, but would be handy if it could operate on regular datetime variables with auxiliary arrays--although it's generally not too inconvenient to just go ahead and create the needed timetable(s).
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!