Function interpolation by solving linear system

조회 수: 4 (최근 30일)
Lucas
Lucas 2016년 7월 4일
댓글: Lucas 2016년 7월 5일
For interpolate a data set into an nth degree polynomial, we have to have n + 1 (x,...,(f(x,...))) . It means, for example, that if I want interpolate a data points into a third degree polynomial, I have to be four data points.
Ok, however, if I want, for example, interpolate n + x points (x is a natural number / x > 1) into a nth degree polynomial, I will have a linear system with more equations than variables. Can Matlab solve this interpolation case? For example: can Matlab interpolate sin (x) = z, with x = 0, 0.25, 0.5, 0.75, 1, 1.25,..., 90, into a fifth degree polynomial?

답변 (1개)

KSSV
KSSV 2016년 7월 4일
clc; clear all
x = linspace(0,pi/2,50) ;
y = sin(x) ;
plot(x,y,'r')
n = 5 ; % order of the polynomial
p = polyfit(x,y,n) ;
x1 = linspace(0,pi/2,100);
y1 = polyval(p,x1);
hold on
plot(x1,y1,'.b' )
  댓글 수: 1
Lucas
Lucas 2016년 7월 5일
I spoke sine function just for give an example. What I really wish is to interpolate an arbitrary n + x points (x is natural number and greater than 1) into a nth degree polynomial. For example: I want interpolate 100 points, without know the function it belongs, into a 5th degree function. It's possible in Matlab, without Runge's phenomenon?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by