Second order polynomial coefficients with one equation
古いコメントを表示
Hi! I have the following equation: y=c*u+d*u^2
Known variables are y and u for a given timeseries. c and d are unknown constants. Observe that it don't exist a constant term in the equation.
I'm sure that one solution lies within least squares, but I've sort of given up without assistance. Is there another, less complex way to solve this pherhaps?
Anyone who could help progress with this problem?
Thanks!
3 件のコメント
Star Strider
2014 年 11 月 30 日
Azzi’s solution will work. All you need to do is to remove the vector of ones.
Andreas Volden
2014 年 11 月 30 日
Star Strider
2014 年 11 月 30 日
My pleasure!
採用された回答
その他の回答 (1 件)
MariapL
2017 年 11 月 19 日
hi , I am new here, looking for a solution for the same problem. I am trying to use what you said in matlab, but its not working. Could you please take a look ? Maybe you will know what I am doing wrong. So I have the same equation: y=aN^2+bN , with coefficient c already set as 0. I am typing in matlab ( my date is a time series)
x=[0 1 2 3 4 5]
y=[100 250 680 150 200 221]
y = alpha1 * x + alpha2 * x^2
alpha = inv(x' * x) * x' * y
But I will need alpha1 and alpha2 to be known in matlab in order for this to work. I dont get what should I do here to get this two coefficient.
4 件のコメント
Star Strider
2017 年 11 月 19 日
See my Answer to your original Question: Estimating two coefficients out of three in quadratic function (link).
MariapL
2017 年 11 月 19 日
thanks :) !
Star Strider
2017 年 11 月 19 日
As always, my pleasure!
Image Analyst
2017 年 11 月 19 日
No, you don't put X into the alpha equation, you put the matrix built from X, like this:
x=[0 1 2 3 4 5]
y=[100 250 680 150 200 221]
plot(x, y, 'b*');
A = [x', x'.^2]
alpha = inv(A' * A) * A' * y'
% yFit = alpha1 * x + alpha2 * x^2
yFit = alpha(1) * x + alpha(2) * x.^2
hold on;
plot(x, yFit, 'rd-');
grid on;
legend('Training data', 'Fitted Data');
カテゴリ
ヘルプ センター および File Exchange で Polynomials についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!