我想要拟合一条曲线。我的数据存储在"x“和"y2”中。为了拟合这条曲线,有一些像" fit“这样的预定义函数。
我的例子:
x = [20 30 40 50 60 70 80 90 100 200];
y = [4.229 2.514 1.714 1.143 0.8 0.629 0.514 0.4 0.349 0.057];
p_0 = 2*10^(-5);
y2 = 10.^(y/20)*p_0;
[xData,yData] = prepareCurveData(x,y2);
fit_type = 'pchipinterp';
[fitresult] = fit(xData,yData,ft);
结果"fitresult“现在作为”1x1CFIT“对象存储在MATLAB工作区中。是否有任何方法可以用我可以手动定义的数组长度来获得适配结果的实际数组?(例如MATLAB工作区: fitresult: 1x3841 double)
发布于 2021-12-08 19:04:47
编辑您的脚本:
fit_type = 'pchipinterp';
[fitresult] = fit(xData,yData,fit_type);
have结果有两类系数和保形插值,每一类中都有一个分量p和 fitresult (x) fitresult =。
Shape-preserving (pchip) interpolant:
fitresult(x) = piecewise polynomial computed from p
Coefficients:
p = coefficient structure
要提取结果,请将这些代码行添加到您的脚本中(名称最多为u):
1. piecewise_polynomial_computed_from_p = fitresult(x)
2. coefficient_structure = fitresult.p
这里,coefficient_structure是一个构造函数:
coefficient_structure =
form: 'pp'
breaks: [20 30 40 50 60 70 80 90 100 200]
coefs: [9x4 double]
pieces: 9
order: 4
dim: 1
要从it类型提取结果,例如:
Breaks = coefficient_structure.breaks
结果是:
Breaks =
20 30 40 50 60 70 80 90 100 200
https://stackoverflow.com/questions/70279876
复制相似问题