【发布时间】:2016-03-19 11:33:07
【问题描述】:
Matlab fit 无疑是有用的,但不清楚如何将其用作函数 除了官网给出的微不足道的整合和分化: http://uk.mathworks.com/help/curvefit/example-differentiating-and-integrating-a-fit.html
例如,给定存储在对象“曲线”中的拟合,可以评估 曲线(x)得到一个数字。但是一个人会怎么做,例如整合 |curve(x)|^2 (除了笨拙地创建一个新的拟合)?天真地尝试
curve = fit(x_vals,y_vals,'smoothingspline');
integral(curve(x)*curve(x), 0, 1)
给出一个错误:
Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the 'ArrayValued' option to true.
我还尝试通过为被积函数(如下)定义一个普通函数和一个隐式函数来解决问题,但两者都给出了相同的错误。
func=@(x)(curve(x))...; % trial solution 1
function func_val=func(curve, x)...; % trial solution 2
【问题讨论】:
标签: matlab curve-fitting data-fitting