Created
June 4, 2011 09:52
-
-
Save vertexclique/1007764 to your computer and use it in GitHub Desktop.
Derive an equation from point like (x,y), its arguments are x=[x0,x1,...,yn] and y=[y0,y1,...,yn]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function interpolation(x,y) | |
boyut = length(x); | |
for i=1:boyut | |
for j=1:boyut | |
if( j==1) mat(i,j) = 1; | |
continue; | |
end; | |
mat(i,j) = x(i)^(j-1); | |
end; | |
end; | |
a = pinv(mat)*(y'); | |
syms x; | |
k=0; | |
for j = length(a):-1:1 | |
k = k + a(j)*x^(j-1); | |
end; | |
pretty(k); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment