Queries related to equation fitting in MATLAB. (how to find satistics of the fitted parameter of an equation)

1 次查看(过去 30 天)
I have four questions related to data fitting to an equation:
For instance: a, b, and c are the three constants, which are required to be calculated by using data fitting method in a particular equation.
Hence, my questions are:
(1) How can I calculate initial value of a parameter (for example ‘a’) in the equation which is required to be provided while fitting the equation?
(2) How can I calculate the range of the parameters like a, b, and c in an equation (y = ax2 + bx + c) or any other equation?
(3)How can I calculate the statistics (mean, standard deviation, variance, covariance and student t-test value) of the parameters as of a custom equation, for example, quadratic plateau equation?
x=[0,40,80,100,120,150,170,200],
y=[1865,2855,3608,4057,4343,4389,4415,4478]
y=a*x^2+b*x+c, x < xc(Ymax) ....(1)
y=yp, x >= xc(Ymax) ....(2)
I have fitted this equation by given code:
yf = @(b,x) b(1).*(x).^2+b(2)*(x)+b(3);
B0 = [0.006; 21; 1878];
[Bm,normresm] = fminsearch(@(b) norm(y - yf(b,x)), B0);
a=Bm(1);
b=Bm(2);
c=Bm(3);
xc=-b/(2*a);
p=c-(b^2/(4*a));
if (x < xc)
yfit = a.*x.^2+ b*x+c;
else yfit = p;
end
plot(x,yfit, '*')
hold on
plot(x,y)
hold off
Kindly suggest.
Note: I have already used polyfit command (as suggest by John D'Errico), it was helpful, it also provided me the results. However, I really don’t find it suitable, as there is no option to customize the equation. Can I find these statistics by any code?
(4) Does anybody know on which basis MATLAB choose the range of parameter if we are not giving any range for the parameter?
  2 个评论
John D'Errico
John D'Errico 2018-12-29
Hmm. Lets see. I spent a long time answering your last question. Then you accepted a different answer, one that said nothing at all about the question you were asking. (When you accept a random answer that is not relevant to your question, you may end up convincing someone later on who sees your question and that answer, that what was said there was correct.)
Now, you ask pretty much the same question, without having apparently ever reading my answer.
I'd suggest using polyfitn, downloaded from the file exchange, since it can estimate a general polynomial model form, not a limited form like that in polyfit. As well, polyfitn also returns most of the parameters you requested.
But sorry. I'm not going to waste my time in answering more of your questions on this exact same topic, as you seem not to read the answers.
As far as the basis MATLAB uses to limit the parameter ranges, again, you need to start learning about regression analysis. But if you do not limit the parameter range, then no limit is applied. Somehow that seems logical.
madhuri dubey
madhuri dubey 2018-12-29
I will be more precise for accepting anyone's answers in future. I am very thankfull that you have spent much time for answering my question. Yeah, you are right I did not give much time for understanding your answer. But now I will read your previous reply very carefully. And if I'll have any query or doubt then only I will ask to you. Thanks for your previous help.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by