Hello I wanted to write code in matlab "without using any toolbox" to do the following things, can we do like this?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Image Analyst
am 4 Dez. 2013
How can you have an error (meaning calc-actual) if you don't have the coefficients yet?
Antworten (1)
Image Analyst
am 4 Dez. 2013
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.
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!