作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
从一条曲线的绘图出发,是否有可能得到该曲线的参数方程?
特别是,x={1 2 3 4 5 6....} x 轴,y = {a b c d e f ....} 对应的 y 轴。我有情节(x,y)。
现在,我如何获得描述绘制曲线的方程式?是否可以显示从样条插值开始的参数方程?
谢谢
最佳答案
如果您想在图表旁边显示多项式拟合函数,以下示例应该有所帮助:
x=-3:.1:3;
y=4*x.^3-5*x.^2-7.*x+2+10*rand(1,61);
p=polyfit(x,y,3); %# third order polynomial fit, p=[a,b,c,d] of ax^3+bx^2+cx+d
yfit=polyval(p,x); %# evaluate the curve fit over x
plot(x,y,'.')
hold on
plot(x,yfit,'-g')
equation=sprintf('y=%2.2gx^3+%2.2gx^2+%2.2gx+%2.2g',p); %# format string for equation
equation=strrep(equation,'+-','-'); %# replace any redundant signs
text(-1,-80,equation) %# place equation string on graph
legend('Data','Fit','Location','northwest')
关于插值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3831321/
我是一名优秀的程序员,十分优秀!