Convert column of data from cumulative to relative values
Show older comments
I have what I think is a relatively simple question that I haven't been able to figure out the answer to. I had different users complete the same test multiple times, and have 2 columns of data (A and B) in matrix 'TestData' as below. Column A is a user number and Column B is the cumulative test number (how many TOTAL test have been taken)
Col A Col B
1 1
1 2
1 3
1 4
1 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
I would like to be able to create another column, column C, that converts the cumulative test number to a number that is relative to a given user. In other words, I want column C to show the test number WITHIN a particular users data, as below.
Col A Col B Col C
1 1 1
1 2 2
1 3 3
1 4 4
1 5 5
2 6 1
2 7 2
2 8 3
3 9 1
3 10 2
3 11 3
3 12 4
3 13 5
3 14 6
Any help would be appreciated, I've been stuck on this for awhile and was wondering if anyone has a straightforward way to approach this. Thanks in advance.
JD
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!