简体   繁体   中英

Solving non linear equations in Matlab

consider the following equations :

eqn1 =


    sin(t6)*(cos(t4)*sin(t1) + sin(t4)*(cos(t1)*sin(t2)*sin(t3) - cos(t1)*cos(t2)*cos(t3))) + cos(t6)*(cos(t5)*(sin(t1)*sin(t4) - cos(t4)*(cos(t1)*sin(t2)*sin(t3) - cos(t1)*cos(t2)*cos(t3))) - sin(t5)*(cos(t1)*cos(t2)*sin(t3) + cos(t1)*cos(t3)*sin(t2))) == 1


eqn2 =


    cos(t6)*(cos(t4)*sin(t1) + sin(t4)*(cos(t1)*sin(t2)*sin(t3) - cos(t1)*cos(t2)*cos(t3))) - sin(t6)*(cos(t5)*(sin(t1)*sin(t4) - cos(t4)*(cos(t1)*sin(t2)*sin(t3) - cos(t1)*cos(t2)*cos(t3))) - sin(t5)*(cos(t1)*cos(t2)*sin(t3) + cos(t1)*cos(t3)*sin(t2))) == 0


eqn3 =


    - sin(t5)*(sin(t1)*sin(t4) - cos(t4)*(cos(t1)*sin(t2)*sin(t3) - cos(t1)*cos(t2)*cos(t3))) - cos(t5)*(cos(t1)*cos(t2)*sin(t3) + cos(t1)*cos(t3)*sin(t2)) == 0


eqn4 =


    cos(t1)/100 + (19*cos(t1)*cos(t2))/100 - (21*cos(t1)*sin(t2)*sin(t3))/1000 + (21*cos(t1)*cos(t2)*cos(t3))/1000 - (219*cos(t1)*cos(t2)*sin(t3))/1000 - (219*cos(t1)*cos(t3)*sin(t2))/1000 == 619/1000


eqn5 =


    - sin(t6)*(cos(t1)*cos(t4) - sin(t4)*(sin(t1)*sin(t2)*sin(t3) - cos(t2)*cos(t3)*sin(t1))) - cos(t6)*(cos(t5)*(cos(t1)*sin(t4) + cos(t4)*(sin(t1)*sin(t2)*sin(t3) - cos(t2)*cos(t3)*sin(t1))) + sin(t5)*(cos(t2)*sin(t1)*sin(t3) + cos(t3)*sin(t1)*sin(t2))) == 0


eqn6 =


    sin(t6)*(cos(t5)*(cos(t1)*sin(t4) + cos(t4)*(sin(t1)*sin(t2)*sin(t3) - cos(t2)*cos(t3)*sin(t1))) + sin(t5)*(cos(t2)*sin(t1)*sin(t3) + cos(t3)*sin(t1)*sin(t2))) - cos(t6)*(cos(t1)*cos(t4) - sin(t4)*(sin(t1)*sin(t2)*sin(t3) - cos(t2)*cos(t3)*sin(t1))) == 1


eqn7 =


    sin(t5)*(cos(t1)*sin(t4) + cos(t4)*(sin(t1)*sin(t2)*sin(t3) - cos(t2)*cos(t3)*sin(t1))) - cos(t5)*(cos(t2)*sin(t1)*sin(t3) + cos(t3)*sin(t1)*sin(t2)) == 0


eqn8 =


    sin(t1)/100 + (19*cos(t2)*sin(t1))/100 - (219*cos(t2)*sin(t1)*sin(t3))/1000 - (219*cos(t3)*sin(t1)*sin(t2))/1000 - (21*sin(t1)*sin(t2)*sin(t3))/1000 + (21*cos(t2)*cos(t3)*sin(t1))/1000 == 0


eqn9 =


    sin(t4)*sin(t6)*(cos(t2)*sin(t3) + cos(t3)*sin(t2)) - cos(t6)*(sin(t5)*(cos(t2)*cos(t3) - sin(t2)*sin(t3)) + cos(t4)*cos(t5)*(cos(t2)*sin(t3) + cos(t3)*sin(t2))) == 0


eqn10 =


    sin(t6)*(sin(t5)*(cos(t2)*cos(t3) - sin(t2)*sin(t3)) + cos(t4)*cos(t5)*(cos(t2)*sin(t3) + cos(t3)*sin(t2))) + cos(t6)*sin(t4)*(cos(t2)*sin(t3) + cos(t3)*sin(t2)) == 0


eqn11 =


    cos(t4)*sin(t5)*(cos(t2)*sin(t3) + cos(t3)*sin(t2)) - cos(t5)*(cos(t2)*cos(t3) - sin(t2)*sin(t3)) == 1


eqn12 =


    (219*sin(t2)*sin(t3))/1000 - (219*cos(t2)*cos(t3))/1000 - (21*cos(t2)*sin(t3))/1000 - (21*cos(t3)*sin(t2))/1000 - (19*sin(t2))/100 == 261/1000

is there a function that can solve these equations ?

fminsearch should do the trick.

https://de.mathworks.com/help/matlab/ref/fminsearch.html

Notice that solving non-linear equations may lead to local optima instead of global optima if the problem isn't convex. You can't really be sure to be globally optimal in many practical cases.

You would need to reformulate this to make it a minimization problem though.

f(x)=1 for example could be written as minimize abs(f(x)-1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM