Is there a way to extract dynamic values of timeseries without hardcoding?

2 views (last 30 days)
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 Comments

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by