Hello I wanted to write code in matlab "without using any toolbox" to do the following things, can we do like this?

1 次查看(过去 30 天)
This is the equation calc_value = C0+C1*N+C2*N^2+C3*P1+C4*P2
where C0-C4 = coefficients N, P1, P2 = input values Now suppose the actual value = x
So, error = calc_value - actual value(x)
I squared the error = error^2
Now I want to minimize the sum of error^2 by adjusting the coefficients C0-C4 in the above equations (like we use solver in excel)
Note: Here the actual values and the inputs are available, I don't want to use any toolboxes
this is my table
N N^2 P1 P2 calc actual error error^2
please help if anyone has the idea...
Thanks Vishal
  3 个评论
Vishal Halale
Vishal Halale 2013-12-5
At start I am assuming the coefficients c0-c4 = 1 then with the help of that I am calculating the value and with using those values finding the error. Then again minimizing the error by adjusting the assumed coefficients. Did you get it?

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2013-12-4
Can't you just use least squares, like
coefficients = calc_value / yourTable;
or something like that? Of course the table would not include calc, actual, error, and must have a column of 1's to start
1, N1, N1^2, P11, P21;
1, N2, N2^2, P12, P22;
1, N3, N3^2, P13, P23;
etc.
Or use the standard least squares solution
Where X is the table I gave above, and y is your calc_values, and beta is your Cn coefficients.
  1 个评论
Vishal Halale
Vishal Halale 2013-12-5
Hey Thanks for the reply. Here See this Image It will give you the clear idea what I wanted. Please write some code also if you know, coz I am new to matlab. All I wanted out of this table is the correct/matlab calculated values of c0-c4 which will minimize the error^2.
Thanks.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by