曲线拟合通过matlab中的特定点

时间:2017-04-12 06:32:43

标签: matlab curve-fitting

如果我有数据点x和y,每行15行和一列,我如何强制线性曲线拟合通过一个点,例如(x = 1,y = 15)?

谢谢,

编辑以包含我的数据点。

x = [5.998,6.477,6.477,6.477,8.789,11.480,12,12,13.53,17.65,18.16,19.91,23.48,25.42,31.17]; y = [17.5,26.9,24.87,63.38,26.5,32.21,30.34,84.6,41.24,52.91,79.77,47.31,76.81,51.8,57.85];

1 个答案:

答案 0 :(得分:1)

嗯,等式是y = kx+n => n = 15-k

fit(..., @(k,x)(k*x+15-k))

如果你想要更多的一般约束(比如n阶多项式应该通过A,B,C点),你应该看看https://www.mathworks.com/matlabcentral/answers/94272-how-do-i-constrain-a-fitted-curve-through-specific-points-like-the-origin-in-matlab