24小时热门版块排行榜    

查看: 3460  |  回复: 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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[教师之家] 跳槽后在研项目怎么办? +5 简单化xn 2026-08-22 10/500 2026-08-23 12:38 by 简单化xn
[基金申请] 什么时候开奖? +9 CrisMessi 2026-08-18 10/500 2026-08-23 12:03 by 丶昵称占用
[基金申请] 2026国自然函评费到账 +15 羊腰板 2026-08-21 16/800 2026-08-23 10:45 by process2012
[基金申请] 今天放榜吗? +15 布布和一二 2026-08-19 16/800 2026-08-23 09:55 by 张春生
[基金申请] 93BebMhtakh前后11位开头都是大写 +7 且听虎啸 2026-08-17 8/400 2026-08-22 21:55 by 医学老男孩
[基金申请] 范进中举一文的中心思想 +3 炎黄贵胄 2026-08-22 4/200 2026-08-22 20:02 by mycsru
[基金申请] filecode,4个jtjc了 +13 ziyangfang 2026-08-19 16/800 2026-08-22 17:08 by WH3796
[基金申请] 今天基金会出结果吗?20260819 +16 kkkl_v 2026-08-19 17/850 2026-08-22 16:12 by 阿布Abu
[基金申请] 时间戳今天,20号变了 +5 archvillain 2026-08-20 5/250 2026-08-22 06:12 by hui_daxiao
[基金申请] 放榜前的不淡定 40+4 snowwithsea 2026-08-19 14/700 2026-08-21 23:51 by cratir
[基金申请] 今日不放榜?网传国自然预计 8 月 27 日可查结果 +16 医学老男孩 2026-08-20 20/1000 2026-08-21 21:13 by Ldrop2023
[基金申请] 看来今天不会放榜了? +8 chengyan1220 2026-08-21 11/550 2026-08-21 17:52 by dcqxinyang
[基金申请] 应该是下周三26日公布了吧? +4 哈哈蛤? 2026-08-21 4/200 2026-08-21 10:58 by Vivilian
[论文投稿] 投稿咨询 +5 wwm09 2026-08-17 7/350 2026-08-21 10:11 by 期刊论文帮手
[基金申请] 今天放榜没戏了吧 +9 yuleib84 2026-08-19 11/550 2026-08-21 10:06 by gltch
[基金申请] 基金啊基金 +4 longfie172 2026-08-20 4/200 2026-08-21 08:58 by mark mao
[基金申请] 估计是周四 +3 archvillain 2026-08-18 3/150 2026-08-21 01:48 by jnhyjjm
[基金申请] 重要消息,中午系统在维护 +11 yuleib84 2026-08-18 12/600 2026-08-20 11:09 by xskun
[基金申请] 朋友圈看到的 +6 wangzilk 2026-08-18 8/400 2026-08-19 10:55 by Haru815
[基金申请] 今天维护系统维护 祝所有人 高中 +8 gjjjzhong 2026-08-18 9/450 2026-08-18 13:01 by 家与远方
信息提示
请填处理意见