How to interpolate each part of values of one row matrix

조회 수: 2 (최근 30일)
Lukas Poviser
Lukas Poviser 2021년 4월 12일
답변: Shadaab Siddiqie 2021년 4월 15일
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
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
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);

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by