首页 > 其他 > 详细

matlab自定义公式拟合

时间:2019-10-17 10:34:24      阅读:118      评论:0      收藏:0      [点我收藏+]

clc,clear
%定义一个符号变量t
syms t
%写入要拟合数据
x=[0;1;3;10;30;100;300;1000;3000;5000;7000;10000];
y=[0;0.003915;-0.01044;-0.01184;-0.03737;-0.14699;-0.41946;-1.00311;-1.94593;-2.56821;-3.07218;-3.65212];
%编辑要拟合的公式,设置变量,设置系数
ft=fittype(‘a(1-exp(-(t/tau)^beta))‘,‘independent‘,‘t‘,‘coefficients‘,{‘a‘,‘tau‘,‘beta‘});
options = fitoptions(ft);
options.StartPoint=[1 10 1];
%设定拟合所用系数的上下限
options.Lower = [-999999 -99999 0];
options.Upper=[100 99999 1];
%进行拟合
cfun=fit(x,y,ft,options)
%显示拟合函数,数据必须为列向量形式
xi=0:10:10000;
yi=cfun(xi);
figure
plot(x‘,y‘,‘r
‘,xi,yi,‘b-‘);
title(‘拟合函数图形‘);

得到的拟合参数:
cfun =
General model:
cfun(t) = a*(1-exp(-(t/tau)^beta))
Coefficients (with 95% confidence bounds):
a = -5.807 (-6.909, -4.705)
tau = 1.021e+04 (5945, 1.448e+04)
beta = 0.7357 (0.6822, 0.7892)

拟合效果图:

技术分享图片

matlab自定义公式拟合

原文:https://www.cnblogs.com/lucaschan/p/11690383.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!