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

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

11-Garnet

## if function

How to solve this problem

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:YA_10963798)

@YA_10963798 wrote:

I tried to start the calculation from scond value , but still didn't work

No, you didn't. You can't use a range n that way.

At least three options:

1) Use the vector index n on the left hand side at Re, too, and also on the vector in the denominator

2) use the submatrix command to cut off the first value in both vectors and use these new vectors in your formula.

3) redefine the ln function using try...on error ... to return a value (maybe a NaN) in case the original ln function fails.

EDIT: BTW, multiplying with 100% does not make much sense because 100% = 1 😉

9 REPLIES 9
23-Emerald I
(To:YA_10963798)

Try using the boolean equal instead of the left arrow

11-Garnet
(To:Fred_Kohlhepp)

didn't work

24-Ruby V
(To:YA_10963798)

Maybe your soil_type vector does not contain any "z" or "k".

We can't see how your variables are defined, what value(s) they contain.

We don't see how the variables are labelled

We don't see if you are using matrix indices or literal indices

....

24-Ruby V
(To:YA_10963798)

Always post your sheet, not just pictures!!

Replace the local assignment operator by a boolean equal.

Furthermore your program does not consider the case when soil_type is neither "z" nor "k".

11-Garnet
(To:Werner_E)

I did the sheet is attached

can you also help in this error as well

24-Ruby V
(To:YA_10963798)

Main error in the initial question about the if-statement is your use of the for-loop. It requires a start and a stop value if you want it to loop and not only use one single value:

I also deleted the elseif statement and replaced it by a simple else. Now the program considers every eventuality as every value in soil_type which is not "z" is treated as a "k".

Primes help is not that clear and you may have to look at not so obvious examples or the video. The key is that y is supposed to be a range, not a scalar:

Considering your second problem in calculating Re, the reason is that the vector which you use in the nominator contains a zero as its first entry. This would force Prime to take the natural log of zero which of course it refuses to do!

Thats the reason for the error message you get

11-Garnet
(To:Werner_E)

I tried to start the calculation from scond value , but still didn't work

24-Ruby V
(To:YA_10963798)

@YA_10963798 wrote:

I tried to start the calculation from scond value , but still didn't work

No, you didn't. You can't use a range n that way.

At least three options:

1) Use the vector index n on the left hand side at Re, too, and also on the vector in the denominator

2) use the submatrix command to cut off the first value in both vectors and use these new vectors in your formula.

3) redefine the ln function using try...on error ... to return a value (maybe a NaN) in case the original ln function fails.

EDIT: BTW, multiplying with 100% does not make much sense because 100% = 1 😉

20-Turquoise
(To:YA_10963798)