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 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