cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Solving equation with conditional statements

fahmed-2
13-Aquamarine

Solving equation with conditional statements

Hello All,

 

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

fahmed2_0-1689100240566.png

Please help,

 

Thanks

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:fahmed-2)

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

 

View solution in original post

10 REPLIES 10
Werner_E
25-Diamond I
(To:fahmed-2)

  • 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-2
13-Aquamarine
(To:Werner_E)

What if I have two variables to solve!!

fahmed2_0-1689105346676.png

 

Werner_E
25-Diamond I
(To:fahmed-2)


@fahmed-2 wrote:

What if I have two variables to solve!!

 

 


Then you would have to use a solve block.

But two variables and just one equation????

 

BTW, do you really expect non-real results here?

Werner_E_0-1689108527721.png

 

fahmed-2
13-Aquamarine
(To:Werner_E)

Thank you!! I am using solve blocks and looks great. I was wondering is it possible to get the values for a range of paired values. For example, if I choose my pairs of (V, B_f) to be (1000, 3), (2000,5) ..............(6000,6) then I would want the solution pairs for each individual input  and assign them in two other variabes. Here, the values of V (post finding solution) will be assigned to "a" variable and the values of B_f (post finding solution) will be assigned to "b" variable. Please help.

 

fahmed2_0-1689111925448.png

 

fahmed-2
13-Aquamarine
(To:fahmed-2)

My ultimate goal is, based on the following equation, I would like to find the values of qo  for different values of B_f and plot the curve. Please help

fahmed2_1-1689115807128.png

 

 

fahmed-2
13-Aquamarine
(To:fahmed-2)

Thank you @Werner_E . My original intent is ,based on the following equation, I would like to find the values of qo  for different values of B_f and plot the curve. Please help

fahmed2_0-1689116650257.png

 

Werner_E
25-Diamond I
(To:fahmed-2)

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

 

 

Get Bf as a vector by using equal at end of definition trick

Create what is called a parametric Solve Block with a function and parameters. Function is bearing, parameter is Bf.

Use the function with element by element of vector Bf to get a vector answer ans

then plot the values required.

Capture.JPG

Werner_E
25-Diamond I
(To:fahmed-2)

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.

fahmed-2
13-Aquamarine
(To:Werner_E)

Thank you @Werner_E  and @terryhendicott . My heartiest thanks for your generous help.

 

 

Announcements

Top Tags