Is it possibe to find the equation from two data vector like x=0 10 20 30 40 50 60 y=78.54 76.19 73.65 70.86 67.72 64.20 60.19
1 次查看(过去 30 天)
显示 更早的评论
I have two data obtained from experiment.like x=0 10 20 30 40 50 60 y=78.54 76.19 73.65 70.86 67.72 64.20 60.19 from this data I wanna find the equation
1 个评论
Stephen23
2015-10-1
编辑:Stephen23
2015-10-1
There are infinite fucntions that will fit your data, so unless you have some prior knowledge of the model that describes the data then there is no magic tool to discover the best model for some data.
You can easily fit splines, polynomials or lines to model your data.
回答(1 个)
Thorsten
2015-10-1
You can use polyfit to fit a polynominal to your data. A polynominal of order 2 gives a nice fit
p = polyfit(x, y, 2);
plot(x, polyval(p, x), 'r')
hold on
plot(x,y, 'k')
And you can have a look a the residuals
residuals = y - polyval(p, x)
The values in p define your equation, e.g.
p(1)*x^2 + p(2)*x + p(3)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!