How to interpolate each part of values of one row matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
the cyclist
am 12 Apr. 2021
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?
Antworten (1)
Shadaab Siddiqie
am 15 Apr. 2021
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 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!