Bachelor Thesis Help! Dealing with NaN when calculating absolute difference
Show older comments
Dear reader,
I'm working on some gait data for my bachelor thesis. I stubble across the following problem:
I wanna calculate the absolute difference between two consecutive values. When the value is NaN, I want to skip this value and calculate the absolute difference of the next two values. The new variable must not consist any gaps in between values, so it has to be one vector without zeros.
I wrote the following:
for i = start : stop-1; j = i - start+1;
if ContactTimeL(i,1)==NaN;
i = i+1;
else
ADContactTimeL(j,1) = abs(PContactTimeL(j+1,1) - PContactTimeL(j,1));
end
end
The problem is that every time the loops start again, i is ascending with from the next original value instead of i = i +1.
Does anyone know how I can fix this problem?
Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Logical 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!