Skip to main content
12-Amethyst
March 24, 2021
Solved

Multiple Nested If Statements

  • March 24, 2021
  • 2 replies
  • 7360 views

I would like to create a series of nested If statements to calculate kp_figure for Multiple values of Θ (120, 110. 100, 90, 80, 70, 60, and 50), with a secondary If statement for each value of Θ as shown in the calculation for Θ =120.

 

Any assistance would be appreciated.

Best answer by Werner_E

You have an (implicit) multiplication dot between the 15.15 and the polynomial.

You have to separate the two arguments of the min function by a comma:

Werner_E_2-1616647087869.png

 

 

 

2 replies

25-Diamond I
March 24, 2021

You don't need an if-statement to calculate the k value. After all its inefficient to calculate the polynomial twice. Let the min-function do the job:

Werner_E_0-1616562425414.png

 

 

How about defining some functions to do the job?

Werner_E_0-1616561864326.png

I was assuming that both, the polynomial and the max value are different dependent on theta. If thats not the case, the solution can be quite simpler. If for instance the polynomial is the very same for all values of theta (and only dependent on Phi.f, you won't need theta and the conditionals in the function "poly" and you also may consider providing the values for theta and the appropriate max-values in vectors and use "Lookup" to chose the correct value instead of the cascaded if's.

 

idahoan12-AmethystAuthor
12-Amethyst
March 24, 2021

Yes, the maximum value and polynomial are different for each value of theta.  I am trying to develop a  program/routine to calculate k when the values of theta and phi are changed/entered. I like the efficiency of the min function.

23-Emerald IV
March 24, 2021

It appears like this could be what you are after:

LucMeekes_0-1616625994978.png

 

idahoan12-AmethystAuthor
12-Amethyst
March 25, 2021

I'll post this at the end of the replies also.

 

With the = deleted, the poly function works correctly.  Thank you!

 

Now for the min function.  Is this a mislabeling error?

Werner_E25-Diamond IAnswer
25-Diamond I
March 25, 2021

You have an (implicit) multiplication dot between the 15.15 and the polynomial.

You have to separate the two arguments of the min function by a comma:

Werner_E_2-1616647087869.png