for loop to subtract every element from the first element for a given trial
Show older comments
I have two columns with TrialNumber and Minutes in the table tt (please see attached).
I'm trying to get the Minutes to start from 0 for each of the trials. To do this, I am trying to subtract every element from the first element in a trial and that will restart time for each trial and have each trial start from 0.
I've attempted this with a for loop but it doesn't seem to be working:
allTrials = unique(tt.TrialNumber);
for ii = 1:length(allTrials)
bb = find(tt.TrialNumber == allTrials(ii));
for jj = 2:length(bb)
nn(jj) = tt.Minutes(bb(jj)) - tt.Minutes(bb(1));
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Work with Components 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!