How to interpolate each part of values of one row matrix
1 次查看(过去 30 天)
显示 更早的评论
Hi I have some sampled data. Data consist of one row matrix that consis of values and NaN (or 0, it's easy to change it). And I would like to interpolate each part of values (or segment) of matrice to (for example) 60 samples.
Example:
Sampled data:
A = [ 3 6 4 5 6 NaN 8 9 10 NaN NaN NaN 13 14 5 6 0 1 NaN NaN 2 3 NaN NaN NaN 9 1 5 NaN 2 8 NaN]
Result:
Matrix B =
3 6 4 5 6 7
8 8.5 9 9.5 10 10.5
13 14 5 6 0 1
2 2.2 2.4 2.6 2.8 3
etc.
Every row would be one interpolated segment. And every row would be same size (60 samples).
1 个评论
the cyclist
2021-4-12
I don't understand your rule for the interpolation, or your example result.
I think I understand where the "7" comes from in the first row of B -- linear interpolation of 6 and 8.
But the replacement of the next three NaNs is puzzling to me. I guess I would have expected them to be linear interpolation between 10 and 13, but they are not. (I am similarly confused about the later NaNs.)
Can you give a little more explanation of how you arrived at those interpolated values?
回答(1 个)
Shadaab Siddiqie
2021-4-15
From my understanding you want to interpolate NaN in your array with values. Your interpolation function is not clear but you can use function form inpaint_nans which has many interpolation.
A = [ 3 6 4 5 6 NaN 8 9 10 NaN NaN NaN 13 14 5 6 0 1 NaN NaN 2 3 NaN NaN NaN 9 1 5 NaN 2 8 NaN];
interpolatedA = inpint_nans(A,0);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!