Is there a way to extract dynamic values of timeseries without hardcoding?
4 ビュー (過去 30 日間)
古いコメントを表示
I have a multiple timeseries that goe as follows:
Subject 1 (13x1):
1
1
1
2
2
2
5
5
5
5
8
8
8
Subject 2:
1
1
1
4
4
4
4
4
7
7
9
9
9
9
9
9
I want to calculate the difference between every change and the first value (1), and then I also want to caclualte the difference between the multiple conditions (e.g. 7-4=3, 5-2=3, etc). For one subject, I could hard code the section of the timeseries as follows and do as follows:
Example for subject 1:
timeseries(11)-timeseries(2)=6
Example for subject 2:
timeseries(4)-timeseries(1)=3
Is there a way to do this without hardcoding the part of the timeseries?
Thanks a ton
2 件のコメント
Matt
2022 年 10 月 21 日
The function unique (https://fr.mathworks.com/help/matlab/ref/double.unique.html) can help you do that.
C = unique(timeserie);
C-timeserie(1)% this is the difference between all the multiples elements and the first element
if you want the difference between all the uniques elements you can do a loop on the elements of C to compute all the possible variations. Something like this :
for ii=1:length(C)
for jj=1:length(C)
diff(ii,jj) = C(ii)-C(jj);
end
end
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Time Series についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!