Hello Matlab experts, I have a 5x1 symbolic named "Eq" with following expressions in it, with 5 unknown variables, T2, T3, T4, T5, T6. - 0.5*T2^2 - 0.167*T2*T3 - 32.0*T2 - 0.0833*T3^2 + 1.5*T3 - 2610.0 == 0.0 - 0.0833*T2^2 - 0.167*T2*T3 + 0.5*T2 - 0.5*T3^2 - 0.167*T3*T4 - 2.0*T3 - 0.0833*T4^2 + 1.5*T4 == 0.0 - 0.0833*T3^2 - 0.167*T3*T4 + 0.5*T3 - 0.5*T4^2 - 0.167*T4*T5 - 2.0*T4 - 0.0833*T5^2 + 1.5*T5 == 0.0 - 0.0833*T4^2 - 0.167*T4*T5 + 0.5*T4 - 0.5*T5^2 - 0.167*T5*T6 - 2.0*T5 - 0.0833*T6^2 + 1.5*T6 == 0.0 - 0.0833*T5^2 - 0.167*T5*T6 + 0.5*T5 - 0.25*T6^2 - 0.5*T6 - 5.0 == 0.0 To use fsolve, I need to change them into the following expressions, with changing T2 -> T(1), T3 -> T(2), T4 -> T(3), T5 -> T(4), T6 -> T(5). F(1) = - 0.5*T(1)^2 - 0.167*T(1)*T(2) - 32.0*T(1) - 0.0833*T(2)^2 + 1.5*T(2) - 2610.0; F(2) = - 0.0833*T(1)^2 - 0.167*T(1)*T(2) + 0.5*T(1) - 0.5*T(2)^2 - 0.167*T(2)*T(3) - 2.0*T(2) - 0.0833*T(3)^2 + 1.5*T(3); F(3) = - 0.0833*T(2)^2 - 0.167*T(2)*T(3) + 0.5*T(2) - 0.5*T(3)^2 - 0.167*T(3)*T(4) - 2.0*T(3) - 0.0833*T(4)^2 + 1.5*T(4); F(4) = - 0.0833*T(3)^2 - 0.167*T(3)*T(4) + 0.5*T(3) - 0.5*T(4)^2 - 0.167*T(4)*T(5) - 2.0*T(4) - 0.0833*T(5)^2 + 1.5*T(5); F(5) = - 0.0833*T(4)^2 - 0.167*T(4)*T(5) + 0.5*T(4) - 0.25*T(5)^2 - 0.5*T(5) - 5.0; Is there any way to change without changing one by one manually?
Kshitij Singh answered .
2025-11-20
F = matlabFunction(lhs(Eqn)-rhs(Eqn), 'vars', {[T2, T3, T4, T5, T6] })