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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

if function

YA_10963798
14-Alexandrite

if function

How to solve this problem

YA_10963798_0-1716286079159.png

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(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 😉

View solution in original post

9 REPLIES 9

Try using the boolean equal instead of the left arrow

Fred_Kohlhepp_0-1716289047548.png

 

YA_10963798_0-1716289371345.png

 didn't work

 

Werner_E
25-Diamond I
(To:YA_10963798)

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

Again: Post your sheet!!

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

....

Werner_E
25-Diamond I
(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".

YA_10963798
14-Alexandrite
(To:Werner_E)

I did the sheet is attached

can you also help in this error as well 

YA_10963798_0-1716289714613.png

 

Werner_E
25-Diamond I
(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:

Werner_E_1-1716290386117.png

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:

Werner_E_4-1716290971981.png

 

 

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!

Werner_E_2-1716290708801.png

Thats the reason for the error message you get

Werner_E_3-1716290749622.png

 

YA_10963798
14-Alexandrite
(To:Werner_E)

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

YA_10963798_0-1716290917951.png

 

Werner_E
25-Diamond I
(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 😉

ttokoro
20-Turquoise
(To:YA_10963798)

If adding 

ttokoro_0-1716295217326.png

You get this result.

 

image.pngimage.png

Announcements

Top Tags