How can i extrapolate data?
古いコメントを表示
I have two data set. How can i extrapolate for NaN?
fs=[0.0001 0.001 0.01 0.1 1 5 25 50 100];
P=[NaN NaN NaN NaN NaN 0.1 0.5 1.2 2.7];
採用された回答
その他の回答 (1 件)
Ameer Hamza
2020 年 3 月 27 日
編集済み: Ameer Hamza
2020 年 3 月 27 日
The following code linear extrapolation on the available data.
fs=[0.0001 0.001 0.01 0.1 1 5 25 50 100];
P=[NaN NaN NaN NaN NaN 0.1 0.5 1.2 2.7];
% filter data without nan
fs_ = fs(~isnan(P));
P_ = P(~isnan(P));
P_extarp = interp1(fs_, P_, fs, 'linear', 'extrap');
2 件のコメント
John D'Errico
2020 年 3 月 27 日
Note that the linear extrapolant uses only the lowest two data points, essentially ignoring the upper data points for this purpose. As such, it implicitly fits a straight line thrugh the points at fs == 5 and 25, then extrapolating that all the way down to 1, .01, .001, .0001. It is as if you had used polyfit on those two data points.
An important feature of that approximation is it does not make any assumption of what happens at fs==0. The data itself for those two points has the points as
[fs;P]
ans =
0.0001 0.001 0.01 0.1 1 5 25 50 100
NaN NaN NaN NaN NaN 0.1 0.5 1.2 2.7
I am fairly confident that this data was made up, as those first two (non-nan) data points happen to fall on a line that passes exactly through the origin. Thus the linear extrpolant used will be this one:
poly1model = polyfit(fs(6:7),P(6:7),1)
poly1model =
0.02 -1.7691e-17
Thus a straight line with a constant term of zero (though there is some floating point trash in the result) and a slope of 0.02.
If the data was not made up (as I am again fairly confident this was, or at least it was heaily rounded) then the linear extrapolant might not be so well behaved.
Ameer Hamza
2020 年 3 月 27 日
Good analysis. Yes, It appears from values that the OP just created these values as an example, and the actual dataset might have different characteristics. Since OP didn't provide any information, so my solution was just an example. Unless OP provides the real dataset, we can just speculate.
カテゴリ
ヘルプ センター および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
