Extrapolating data outside given data

40 ビュー (過去 30 日間)
Taha Rizvi
Taha Rizvi 2019 年 11 月 10 日
コメント済み: Taha Rizvi 2019 年 11 月 10 日
Hi,
I need to extrapolate 15 points of data with 3 given corresponding x and y values. is there any way to do it?
%x = 1:15, y = 9.85 9.82 9.84 (extrapolate to 15)
any help would be greatly appreciated !!
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 11 月 10 日
Could you confirm that you have an x vector of length 3, and a y vector of length 3?
Is the task to extrapolate y where x would be 15? Or is the task to interpolate at 15 different locations, such as linspace(min(x), max(x), 15) ?
Taha Rizvi
Taha Rizvi 2019 年 11 月 10 日
Hi Walter,
sorry for that, the current x vector is x = [1 2 3] to correspond with that y vector.
and yes i need to extrapolate data all the way up to 15, so in total i would have 15 y values for 15 x values. like you said linspace(min(x), max(x), 15)

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 11 月 10 日
xq = linspace(min(x), max(x), 15);
yq = interp1(x, y, xq);
This does not extrapolate to x = 15, this interpolates at 1, 8/7, 9/7, 10/7, 11/7 and so on.
If you were trying to extrapolate out to x = 15, then
xq = 1 : 15;
yq = interp1(x, y, xq, 'linear', 'extrap')
or 'spline', 'extrap'
Or you could,
xq = 1 : 15;
[P, S, MU] = polyfit(x, y, 2);
yq = polyval(P, xq, S, MU);
  1 件のコメント
Taha Rizvi
Taha Rizvi 2019 年 11 月 10 日
Im a beginner in Matlab, could you explain how that code is able to extrapolate from those values please?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by