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 件のコメント
Image Analyst
Image Analyst 2013 年 12 月 4 日
How can you have an error (meaning calc-actual) if you don't have the coefficients yet?
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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by