Warning: Explicit solution could not be found

I am new to MATLAB. Kindly help me with the following problem. My code is the following.
syms n D U_1 U_2 U_3 U_4 I_m m C_o C_p C_h
eq=(6*C_h*I_m^2 + 12*C_o*D - (6*C_p*(D - I_m*n)^2)/n^2 - (12*C_p*I_m*(D - I_m*n))/n)/(12*D) - (((m*(n/365)^(m - 1)*(((n - 1)^(1 - m) + n^(1 - m) - 2)/(2*m - 2) - 1/2))/365 - (((m - 1)/(n - 1)^m + (m - 1)/n^m)*(n/365)^m)/(2*m - 2))*(2*U_1 + I_m^2*U_3 + (U_4*(D - I_m*n)^2)/n^2))/(12*D) + (U_2*(1/(2*(n - 1)) + 1/(2*n)))/(6*D) + (((n/365)^m*(((n - 1)^(1 - m) + n^(1 - m) - 2)/(2*m - 2) - 1/2) - 1)*((2*U_4*(D - I_m*n)^2)/n^3 + (2*I_m*U_4*(D - I_m*n))/n^2))/(12*D)==0
soln=solve(eq,n)
It does not provide an explicit expression for n. It shows
Warning: Explicit solution could not be found. > In solve at 179 In solveforn at 3
soln = [ empty sym ]
How could I solve the equation and find an expression for n?

Answers (2)

If you have lot of symbolic variables MATLAB's symbolic engine won't be able to solve such equations
After using expand, many of the terms in your equation have ‘(n - 1)^m’, ‘n^(m + 3)’, or something similar, so an analytical solution is not possible.
Convert ‘eq’ to an anonymous function (use matlabFunction), provide values for the variables, and use a numeric solver instead.

Asked:

on 22 Oct 2018

Answered:

on 22 Oct 2018

Community Treasure Hunt

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

Start Hunting!