7 views (last 30 days)

This is my actual equation:

58.8*(550)=0.5*37*0.002377*x^3*(0.02+0.062((2*960)/(0.002377*37*x^2))^2)

The real values are 40.2498, 317.889

I've already tried fzero to no avail.

Thanks

Dana
on 24 Jun 2020

A few things:

First, you're missing a * between 0.062 and the ( that follows it.

Second, I have no trouble solving this equation with fzero. You say you tried fzero but it didn't work. Can you post your code?

Third, fzero is actually not the best way to go about finding all of the multiple solutions to an equation, since it only looks for a sinlge solution and stops as soon as it does. Luckily, your equation can be converted to a polynomial form very easily: multiply both sides by x to get , which is a quartic equation in x, the solutions of which can be found in MATLAB via the roots function: roots([a,0,0,c,b]) will give you the answers.

In your case, the code:

g = 0.5*37*0.002377;

h = ((2*960)/(0.002377*37))^2;

a = 0.02*g;

b = 0.062*g*h;

c = -58.8*(550);

rts = roots([a,0,0,c,b])

returns all the solutions (including complex ones):

rts =

1.0e+02 *

-1.7907 + 2.8879i

-1.7907 - 2.8879i

3.1789 + 0.0000i

0.4025 + 0.0000i

Since you're not interested in the complex ones, you can extract the real ones via:

rlrts = rts(imag(rts)==0)

which returns

rlrts =

317.8889

40.2498

as desired.

AKARSH KUMAR
on 24 Jun 2020

Refer the docmentation https://www.mathworks.com/help/symbolic/solve.html

James Tursa
on 24 Jun 2020

Edited: James Tursa
on 24 Jun 2020

Just use the roots( ) function. If you have a negative integer power of x in the expression such as x^(-n), then multiply everything by x^n first to give yourself a polynomial to work with, then call roots( ).

0=a*x^(3)+b*x^(-1)+c

becomes

0=a*x^(4)+b+c*x

then feed the coefficients to roots( ):

roots([a,0,0,c,b])

Bjorn Gustavsson
on 24 Jun 2020

This works perfectly fine:

f = @(x ) -58.8*(550) + 0.5*37*0.002377*x.^3.*(0.02+0.062*((2*960)./(0.002377*37*x.^2)).^2);

plot(linspace(0,1000,1001),asinh(f(linspace(0,1000,1001))))

grid on

fzero(f,[100 400])

% 317.89

fzero(f,[10 300])

% 40.25

HTH

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.