ラグランジュ補間と線形補完

조회 수: 46 (최근 30일)
かお
かお 2023년 12월 8일
댓글: かお 2024년 2월 4일
合計25個あるデータのうち,(a1,1),(a2,2),(a3,7),(a1,14),(a1,20)という1,2,7,20番目のデータが存在しいて,それらの間の値と21番~25個のデータを知りたいです。
これらの作業をラグランジュ補間と線形補間で比較しながらやりたいのですが,どうすればいいのでしょうか?
(また,もしもっといい補間方法があれば,併せてお聞きしたいです)
  댓글 수: 1
かお
かお 2023년 12월 8일
(a1,1),(a2,2),(a7,7),(a14,14),(a20,20)でした。すみません。

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

답변 (1개)

COVAO
COVAO 2024년 1월 30일
1次元のデータを補間する関数にintrep1があります。
線形補間の場合、以下のように記述できます。(生成AIを用いてコードを作成しています)
% Original data points
x = [1, 2, 3, 4, 5];
y = [1, 2, 7, 4, 20];
% Extrapolation points
xi = [0:1:10];
% Interpolation result calculation
yi = interp1(x, y, xi, 'linear', 'extrap');
% Plotting the graph
plot(x, y, 'o', xi, yi);
xlabel('x');
ylabel('y');
title('Interpolation with Extrapolation');
legend('Data Points', 'Interpolated Curve');
補間方法であるmethod を'linear'から他の曲線などに変えることができます。
ラグランジュ補間はinterp1のmethodに含まれませんが、File ExchangeのLagrange polynomial interpolation等を利用し、関数を定義すれば計算することができます。
  댓글 수: 1
かお
かお 2024년 2월 4일
なるほど。ありがとうございます。
試させていただきます。

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

카테고리

Help CenterFile Exchange에서 内挿에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!