How I do a Linear extrapolation?

조회 수: 77 (최근 30일)
Paulo Oliveira
Paulo Oliveira 2014년 5월 15일
댓글: Star Strider 2023년 4월 29일
Hi, I have a matrix with 160 numbers, but the first values is nan. How I complete this matrix? Anyone help me? I try the -- interp1 --- but I have only a matrix, I do not have a vector to realize the extrapolation.
Thank you for your attention. Best wishes, Paulo Oliveira
  댓글 수: 2
José-Luis
José-Luis 2014년 5월 15일
Extrapolation is tricky business. Depending on the sort of data different extrapolation methods might be warranted. The closest value? A linear interpolation from the first two points. A cuadratic function using the last three points? A spline of n degree?
Extrapolation caused the crash of the Challenger.
Paulo Oliveira
Paulo Oliveira 2014년 5월 15일
I understand your questions, but as I said, I have 160 values, but 40 are NAN, so I have a 140 values to support,for you what the best way to do the data extrapolation?

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2014년 5월 15일
This works:
% Original vector:
x = 1:10
% Replace the first 4 elements with ‘NaN’:
x(1:4) = NaN
% Create empty elements for the ‘NaN’ elements:
x(isnan(x)) = []
% Extrapolate to fill the empty elements:
xm = interp1(x, -3:0, 'linear', 'extrap')
produces:
xm =
1. 2 3 4
  댓글 수: 4
Anwaar Alghamdi
Anwaar Alghamdi 2022년 11월 24일
편집: Anwaar Alghamdi 2022년 11월 24일
@Star Strider Does this work if I have missing hourly temperature values? (not NaN but 999)
One or two missing values is fine but if a have a whole day missing? Can this preserve the behavior of hourly temprature profile within the day?
Star Strider
Star Strider 2023년 4월 29일
@Anwaar Alghamdi — I just now saw this.
It depends on what the data are and where the values are that are NaN. The fillmissing function would likely be most appropriate.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by