用MATLAB拟合分段函数(不能分开拟合)?
ε=【6.23E-040.007180.013750.020310.026870.033430.039990.046550.053110.059670.066240.07...
ε=【6.23E-04 0.00718 0.01375 0.02031 0.02687 0.03343 0.03999 0.04655 0.05311 0.05967 0.06624 0.0728 0.07936 0.08592 0.09248 0.09904 0.1056 0.11216 0.11873 0.12529 0.13185 0.13841 0.14497 0.15153 0.15809 0.16465 0.17122 0.17778 0.18434 0.1909 0.19746 0.20402 0.21058 0.21714 0.22371 0.23027 0.23683 0.24339 0.24995 0.25651 0.26307 0.26963 0.2762 0.28276 0.28932 0.29588 0.30244 0.309 0.31556 0.32212 0.32869 0.33525 0.34181 0.34837 0.35493 0.36149 0.36805 0.37461 0.38118 0.38774 0.3943 0.40086 0.40742 0.41398 0.42054 0.4271 0.43367 0.44023 0.44679 0.45335 0.45991 0.46647 0.47303 0.47959 0.48616 0.49272 0.49928 0.50584 0.5124 0.51896 0.52552 0.53208 0.53865 0.54521 0.55177 0.55833 0.56489 0.57145 0.57801 0.58457 0.59114 0.5977 0.60426 0.61082 0.61738 0.62394 0.6305 0.63706 0.64363 0.65019 0.65675 0.66331 0.66987 0.67643 0.68299 0.68955 0.69612 0.70268 0.70924 0.7158 0.72236 0.72892 0.73548 0.74204 0.74861 0.75517 0.76173 0.76829 0.77485 0.78141 0.78797 0.79453 0.8011 0.80766 0.81422 0.82078 0.82734 0.8339 0.84046 0.84702 0.85359 0.86015 0.86671 0.87327 0.87983 0.88639 0.89295 0.89951 0.90608 0.91264 0.9192 0.92576 0.93232 0.93888 0.94544 0.952 0.95857 0.96513 0.97169 0.97825 0.98481 0.99137 0.99793 1.00449 1.01106 1.01762 1.02418 1.03074 1.0373】σ=【-0.14451 0.72781 1.60013 2.47244 3.34476 4.21708 5.0894 5.96171 6.83403 7.70635 8.57867 9.45098 10.3233 11.19562 12.06794 12.94026 13.81257 14.68489 15.55416 16.45038 17.37409 18.28017 19.19728 20.12822 21.0444 21.94767 22.88454 23.85573 24.83336 25.82275 26.81399 27.78175 28.78522 29.80691 30.77294 31.67613 32.56394 33.43098 34.26367 35.08313 35.93769 36.74727 37.52967 38.31707 39.07443 39.7685 40.45215 41.11793 41.7535 42.3701 42.94979 43.46953 43.99785 44.49599 44.97277 45.39613 45.84922 46.30512 46.72177 47.11787 47.5441 47.92037 48.26045 48.62424 48.97157 49.32148 49.63157 49.94054 50.22679 50.51818 50.77969 51.02908 51.24387 51.43861 51.65613 51.85769 52.0804 52.3059 52.53727 52.71454 52.89137 53.0765 53.23275 53.35322 53.48667 53.61643 53.70802 53.79853 53.87019 53.943 53.99975 54.0405 54.08403 54.1061 54.09712 54.06856 54.03658 54.00091 53.95408 53.90482 53.84022 53.75593 53.68938 53.63471 53.5591 53.46794 53.36686 53.24739 53.11198 52.9607 52.81042 52.64052 52.48025 52.33669 52.1855 52.02548 51.84399 51.67649 51.51381 51.35395 51.21456 51.0368 50.88068 50.72925 50.5739 50.41298 50.25973 50.10026 49.9257 49.73999 49.56032 49.33946 49.13152 48.92656 48.71361 48.47948 48.23955 48.00303 47.7727 47.54887 47.32095 47.10732 46.89747 46.66252 46.45133 46.2325 46.0123 45.81297 45.60134 45.39475 45.19374 44.99202 44.78741 44.58809 44.39644 44.21351 44.02686 43.83671 43.64289】拟合以上的数据,相关函数及条件见图片,求出函数中的五个参数(见图片)。
展开
1个回答
展开全部
题主给出的拟合分段函数,经分析可以下列方法来实现。
1、创建数据函数,即 [x,y]=data(),将ε和σ的数据存储在其函数中。
2、创建分段函数,func(p,x),利用if判断语句,计算σ_M值。即
if epsilon<=epsilon_th
y=(E1*epsilon+E2*theta2*epsilon1.*(1-exp(-epsilon./(theta2*epsilon1))));
else
y=(exp(-(epsilon-epsilon_th).^m/a).*(E1*epsilon+E2*theta2*epsilon1.*(1-exp(-epsilon./(theta2*epsilon1))))+k*(1-exp(-(epsilon-epsilon_th).^m/a)));
end
3、使用nlinfit函数计算拟合系数p,即 p= nlinfit(x,y,@func,p0)
4、计算拟合值,y1=func(p,x)——σ_M
5、根据y,y1,计算其决定系数 R^2及相关统计值
6、编写代码运行后可以得到如下结果。
更多追问追答
追问
有代码吗?我想跑一个试试。我网上也找了一个案例,不过换了我自己的参数就出现了问题
追答
肯定有代码的,不然怎么出图。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询