Find optimized solution of linear system of equations

1 view (last 30 days)
I have this system of equations and I am willing to find the value of kp, ki, kp
0.1*kd +0.49 = 18;
0.04*kd +0.1*kp +21.6 = 121;
0.04*kd +0.1*ki +0.98 = 438;
1.96*(kd +kp)+ 0.04*ki = 1030;
1.96*ki = 1200;
and kp, ki, kd > 0
Using linsolve of the system, the answer was Inf for all.

Accepted Answer

Star Strider
Star Strider on 24 May 2019
Try this:
syms kd kp ki
Eq1 = 0.1*kd +0.49 == 18;
Eq2 = 0.04*kd +0.1*kp +21.6 == 121;
Eq3 = 0.04*kd +0.1*ki +0.98 == 438;
Eq4 = 1.96*(kd +kp)+ 0.04*ki == 1030;
Eq5 = 1.96*ki == 1200;
[A,b] = equationsToMatrix(Eq1,Eq2,Eq3,Eq4,Eq5);
Coeffs = lsqr(double(A), double(b));
kd = Coeffs(1)
ki = Coeffs(2)
kp = Coeffs(3)
producing:
kd =
912.95079751536
ki =
620.999261482952
kp =
-397.442602821135
The Symbolic Math Toolbox sorts the variables in lexicographical order, so kd>ki>kp, thus the ordering in the results.
Experiment to get the result you want.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!