Skip to content

Instantly share code, notes, and snippets.

@BeMg
Last active June 14, 2017 05:47
Show Gist options
  • Select an option

  • Save BeMg/8a3c417ed325b592b17c60be47174c38 to your computer and use it in GitHub Desktop.

Select an option

Save BeMg/8a3c417ed325b592b17c60be47174c38 to your computer and use it in GitHub Desktop.
NA final
function c = curvefit(x, y)
u = x.*y;
v = [x ones(size(x))];
coef = inv(v'*v)*v'*u;
c(1) = coef(2);
c(2) = coef(1);
c = c';
end

f(x) = a*x+b

使用最靠近的兩個點(30,0.629) (40, 0.2754)

求多項式,解a b。

30*a + b = 0.629
40*a + b = 0.2754

a = -0.03536
b = 1.6898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment