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!
