MATLAB: Solving an equation with one variable

MATLAB and Simulink Student Suitesolve for ysolving equation

How can I solve :
(q*a^4/(E*t^4)) = k1*y/t + k2*(y/t)^3;
q,a,t,E,k1,k2 are constants; where as y is the variable.
How to write matlab code to solve this in terms of y.

Best Answer

  • One approach:
    Out = fzero(@(y) (q*a^4/(E*t^4)) - k1*y/t + k2*(y/t)^3, 2)
    That assumes that all ‘constants’ are scalars. Choose the initial estimate (here 2) that best approximates the value for ‘y’ that you want to find.