How to use linear interpolation on irregular intervals and reset value
1 view (last 30 days)
Show older comments
[ 0 0 0 0 1 0 0 2 0 0 3 0 0 0 1 0 2 0 3 0 0 0 0 1 ]
result=>
[ 0 0.25 0.5 0.75 1 1.33 1.67 2 2.33 2.67 3 0.33 0.67 1 1.33 1.67 2 2.5 3 0 0.25 0.5 0.75 1 ]
Is there any helpful function for this?
2 Comments
Geoff Hayes
on 18 Nov 2015
Hyowon - is there any pattern to the above? Does the 1,2,3 repeat with only the number of zeros changing between non-zero integer?
Accepted Answer
Jan
on 18 Nov 2015
data = [ 0 0 0 0 1 0 0 2 0 0 3 0 0 0 1 0 2 0 3 0 0 0 0 1 ];
match = (data ~= 0);
match([1, end]) = true;
result = interp1(find(match), data(match), find(~match))
More Answers (0)
See Also
Categories
Find more on Interpolation 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!