当前位置:网站首页>数据拟合方法 MATLAB在数学建模中的应用(第二版)
数据拟合方法 MATLAB在数学建模中的应用(第二版)
2022-08-09 14:59:00 【YuNlear】
数据拟合方法
MATLAB在数学建模中的应用(第二版)
多项式拟合
polyfit(X,Y,N)
X,Y为需要拟合的数据,N为拟合的最高次数
返回一个多项式系数的向量P。
polyval(P,X)
P为多项式系数向量,X为要求的数据点,
返回X对应的Y的值。
指定函数拟合
f=fittype('function','independent','自变量','coefficients',{'系数1','系数2',...})
fittype函数用以自定义拟合函数
fit(x,y,f)
fit函数使用自定义的函数f来拟合x,y。
曲线拟合工具箱
Curve Fitting Tool
依次点击Start->Toolboxes->Curve Fitting -> Curve Fitting Tool(cftool)即可打开
也可以在命令行中输入cftool命令打开
例题1 人口预测模型
题目略
%syms t
Y = [33815 33981 34004 34165 34212 34327 34344 34458 34498 34476 34483 34488 34513 34497 34511 34520 34507 34509 34521 34513 34515 34517 34519 34519 34521 34521 34523 34525 34525 34527];
X = [1:30];
x = [1:30];
y = [1:30];
%f = fittype('1/(a+b*exp(-t))','independent','t','coefficient',{'a','b'});
%cfun = fit(X,Y,f);
%Yi = cfun(X);
%plot(X,Y,'r*',X,Yi,'b');
for t = 1:30
x(t) = exp(-t);
y(t) = 1/(Y(1,t));
end
f = polyfit(x,y,1);
for t = 1:30
Yj(t)=1/(f(2)+f(1)*exp(-t));
end
plot(X,Y,'r*',X,Yj,'b');
例题2 薄膜渗透膜的测定
题目略
x = lsqcurvefit(fun,x0,xdata,ydata,lb,ub,options)
lsqcurvefit
用最小二乘求解非线性曲线拟合(数据拟合)问题
详细见链接https://ww2.mathworks.cn/help/optim/ug/lsqcurvefit.html#responsive_offcanvas
t = [100:100:1000];
Cbt = 0.001.*[4.54 4.99 5.35 5.65 5.90 6.10 6.26 6.39 6.50 6.59];
x0 = [0.2,0.05,0.05];%a,b,K的初始值
opts = optimset('lsqcurvefit');
opts = optimset(opts,'PrecondBandWidth',0);
x = lsqcurvefit('curvefun',x0,t,Cbt,[],[],opts);
f = curvefun(x,t);
plot(t,Cbt,'o',t,f,'b');
边栏推荐
- 【深度学习】目标检测之评价指标
- 抱抱脸(hugging face)教程-中文翻译-使用 Tokenizers 的 tokenizers
- CRM定制开发需要多少钱 CRM系统定制开发价格
- 【研究生工作周报】(第十二周)
- 【工具使用】Modbus Slave软件使用详解
- Virtualbox 设置共享文件夹
- [Paper reading] LIME: Low-light Image Enhancement via Illumination Map Estimation (the most complete notes)
- 解决pyqt5 DLL load failed: 找不到指定的程序的问题
- Stetman的读paper小记:Deep Learning Backdoor Survey (Shaofeng Li, Shiqing Ma, Minhui Xue)
- 【Postgraduate Work Weekly】(The third week)
猜你喜欢
随机推荐
【力扣】662. 二叉树最大宽度
【Postgraduate Work Weekly】(Week 5)
【 Leetcode 】 433. The smallest genetic changes
【工具使用】Keil5软件使用-进阶工程配置篇
堆(heap)系列_0x03:堆块 + malloc/new底层 + LFH(WinDbg分析)
Vim实用技巧_0.vim - introduction
go语言基础学习(一起学习go语言)
Vitis部分实验记录
大唐杯5G练习题(二)
规划问题的MATLAB求解——MATLAB在数学建模中的应用(第2版)
抱抱脸(hugging face)教程-中文翻译-分享一个模型
【Leetcode】433. 最小基因变化
【力扣】516. 最长回文子序列
Hold face (hugging face) tutorial - Chinese translation - create a custom framework
抱抱脸(hugging face)教程-中文翻译-对预先训练过的模特进行微调
【工具使用】Modbus Slave软件使用详解
【Postgraduate Work Weekly】(Week 9)
Postgraduate Work Weekly (Week 6)
R-CNN Fast R-CNN Faster R-CNN总结
【深度学习】梳理范数与正则化(二)









