24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 3136  |  回复: 10
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

17_李赏

新虫 (初入文坛)

[求助] matlab曲线拟合及修正 已有2人参与

本人新手,还未对matlab进行深入学习,紧急求助~
已知:x=[8.9 11.7 13.2 13.4 14 14.2 14 10.7 21.671 23.487 20.902 16.507];
    y=[17.698 17.698 27.365 27.365 37.031 37.031 27.365 17.698 66.03 75.696 56.364 37.031]。
请问该如何用matlab拟合出多项式方程y=f(x),然后如何对方程进行修正?
回复此楼

» 收录本帖的淘帖专辑推荐

程序

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

cooooldog

铁杆木虫 (著名写手)

ส็็็

【答案】应助回帖


感谢参与,应助指数 +1
17_李赏: 金币+1, 有帮助 2014-06-29 14:03:46
Matlab不是很熟,我用gnuplot+CTeX拟合了一下,凑合着看看吧:

代码:
CODE:
\documentclass[border=10pt]{standalone}
\usepackage{siunitx}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\begin{filecontents*}{myData.dat}
X     Y
8.900        17.698
11.700        17.698
13.200        27.365
13.400        27.365
14.000        37.031
14.200        37.031
14.000        27.365
10.700        17.698
21.671        66.030
23.487        75.696
20.902        56.364
16.507        37.031
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
width=10cm,
legend style={font=\scriptsize}
}
\begin{axis}[%
xlabel=$x$,
ylabel=$y$,
ymin=0,
xmin=0,
scaled y ticks=base 10:0,
legend cell align = left,
legend pos = north west
]
\addplot[only marks] table {mydata.dat};
\addlegendentry{scatter plot};
\addplot+[no markers,red] table [y={create col/linear regression={y=Y}}]{myData.dat};
\addlegendentry{%
Linear regression:  $y=\pgfmathprintnumber{\pgfplotstableregressiona} x
\pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$};
% polynomial fit
\addplot [no markers, blue] gnuplot [raw gnuplot] { % allows arbitrary gnuplot commands
f(x) = a*x**2+b*x+c;     % Define the function to fit
a=10;b=10; c=10;         % Set reasonable starting values here
fit f(x) 'myData.dat' u 1:2 via a,b,c; % Select the file, starts at col 1 and two variables
plot [x=0:28] f(x);    % Specify the range to plot
set print "parameters.dat";  % Open a file to save the parameters
print a, b, c;                  % Write the parameters to file
};
\addlegendentry{\pgfplotstableread{parameters.dat}\parameters % Open the file Gnuplot wrote
\pgfplotstablegetelem{0}{0}\of\parameters \pgfmathsetmacro\paramA{\pgfplotsretval} % Get first element, save into \paramA
\pgfplotstablegetelem{0}{1}\of\parameters \pgfmathsetmacro\paramB{\pgfplotsretval}
\pgfplotstablegetelem{0}{2}\of\parameters \pgfmathsetmacro\paramC{\pgfplotsretval}
polynomial:$y=\pgfmathprintnumber{\paramA} x^2 \pgfmathprintnumber[print sign]{\paramB} x \pgfmathprintnumber[print sign]{\paramC}$
}
\end{axis}
\end{tikzpicture}
\end{document}

matlab曲线拟合及修正
2014-06-27_21-50-07.png

ส็็็็็็็็็็็็็็็็็็็็
5楼2014-06-27 21:50:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 11 个回答

阿兵将心

木虫 (正式写手)

清虫

matlab里面有选项来拟合的,高斯拟合,多项式拟合什么的都有,你百度就可以看到的。

[ 发自小木虫客户端 ]
学术离我遥远吗
2楼2014-06-27 15:56:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

17_李赏

新虫 (初入文坛)

引用回帖:
2楼: Originally posted by 阿兵将心 at 2014-06-27 15:56:00
matlab里面有选项来拟合的,高斯拟合,多项式拟合什么的都有,你百度就可以看到的。

您好!谢谢您关注我的帖子,拟合函数求出来以后,应该怎么进行修正,您知道吗?
3楼2014-06-27 17:13:33
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

阿兵将心

木虫 (正式写手)

清虫

引用回帖:
3楼: Originally posted by 17_李赏 at 2014-06-27 17:13:33
您好!谢谢您关注我的帖子,拟合函数求出来以后,应该怎么进行修正,您知道吗?...

我还没有仔细看过这方面的东西,有文献资料吗?为何要修正呢,拟合不就是修正吗

[ 发自小木虫客户端 ]
学术离我遥远吗
4楼2014-06-27 20:36:36
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 化工求调剂! +4 RichLi_ 2026-04-06 4/200 2026-04-06 13:12 by 尊的很想上学
[考研] 085600材料与化工301分求调剂院校 +14 刺痛jk 2026-04-06 15/750 2026-04-06 11:57 by lijunpoly
[考研] 319求调剂 +3 handrui 2026-04-05 3/150 2026-04-06 09:33 by jp9609
[考研] 调剂 +3 李广火 2026-04-05 3/150 2026-04-05 18:57 by 蓝云思雨
[考研] 295求调剂 +8 FZAC123 2026-04-03 8/400 2026-04-05 17:46 by 蓝云思雨
[考研] 调剂 +3 好好读书。 2026-04-02 3/150 2026-04-05 13:02 by arrow8852
[考研] 考研调剂 +6 15615482637 2026-04-04 6/300 2026-04-04 22:43 by yu221
[考研] 求调剂 +4 晟功? 2026-04-03 4/200 2026-04-04 21:58 by hemengdong
[考研] 335求调剂 +7 沈清璃 2026-04-03 7/350 2026-04-03 18:55 by lijunpoly
[考研] 土木水利328分求调剂 +6 疾风知劲草666 2026-04-02 6/300 2026-04-03 11:38 by znian
[考研] 071000生物学调剂 +8 知昭蔓 2026-04-02 8/400 2026-04-03 10:36 by macy2011
[考研] 303求调剂 +3 一色清羽 2026-04-02 4/200 2026-04-03 10:22 by 蓝云思雨
[考研] 325分化学调剂 +5 15771691647 2026-04-02 5/250 2026-04-03 09:58 by ChemPharm
[考研] 372分材料与化工(085600)一志愿湖南大学求调剂 +5 蓝笺片 2026-04-02 6/300 2026-04-02 21:37 by dongzh2009
[考研] 348求调剂 +11 zzzzyk123 2026-04-01 11/550 2026-04-02 16:52 by Wang200018
[考研] 材料求调剂 +10 呢呢妮妮 2026-04-01 13/650 2026-04-02 09:17 by olim
[考研] 085600 一志愿9 总分351 求调剂学校 +7 czhcz 2026-03-31 9/450 2026-04-01 19:24 by 无际的草原
[考研] 288资源与环境专硕求调剂,不限专业,有学上就行 +25 lllllos 2026-03-30 26/1300 2026-04-01 09:52 by 一只好果子?
[考研] 一志愿 南京航空航天大学 ,080500材料科学与工程学硕 +10 @taotao 2026-03-31 11/550 2026-04-01 09:43 by xiayizhi
[考研] 一志愿食品科学与工程083200求调剂 +4 XQTJZ 2026-03-30 4/200 2026-03-31 04:10 by fmesaito
信息提示
请填处理意见