Skip to main content
14-Alexandrite
July 11, 2023
Solved

Solving equation with conditional statements

  • July 11, 2023
  • 1 reply
  • 3031 views

Hello All,

 

I am trying to solve an equation that has condition statements and find the roots.

fahmed2_0-1689100240566.png

Please help,

 

Thanks

 

 

Best answer by Werner_E

So you should solve the equation for q0 and not for B.f. You can make the solution a function of B_f as explained in my previous answer.

You may use either a solve block or the root function - its up to you.

Werner_E_0-1689117265946.png

 

You can speedup the calculation significantly (factor 5) by using the approach which I already showed in a previous posting

Werner_E_1-1689118331005.png

Werner_E_2-1689118347669.png

 

1 reply

25-Diamond I
July 11, 2023
  • The symbolics can't do well with conditional expressions, so you should rather use Primes numeric methods (either a solve block with "find" or the "root" command.
  • I guess you rather want to solve for B.f and not for the function Deltaq(B.f)
  • Again you used function names as if it were simple variables! If you use a function, you have to provide the function argument!

Werner_E_1-1689101534910.png

 

You could also do it that way:

Werner_E_2-1689102183634.png

or maybe even that way

Werner_E_0-1689102916019.png

Werner_E_1-1689102943463.png

 

fahmed-214-AlexandriteAuthor
14-Alexandrite
July 11, 2023

What if I have two variables to solve!!

fahmed2_0-1689105346676.png

 

25-Diamond I
July 11, 2023

Your solve block with just one equation but two variables to solve for does not, make much sense!

You may notice that the solve block returns V totally unchanged and only calculates B.f based on the one and only equation you provide.

If your goal is to get the value of B.f for various values of V, then you should change the solve block to only look for B.f and turn it into a function by writing sol(V):=Find(B.f)

 

Then Sol(2000 kN)= gives you the B.f value for this value of V.

 

And you may define a vector Vvec of V-valuse and writing sol(Vvec)= gives you the vector of corresponding B-f values. You should vectorize that function call.