Skip to main content
15-Moonstone
Mar 2, 2026 11:39 AM UTC
Solved

How to do this check

Hi there ,

I need to do this check that F< fy ...

I get the wrong answer .. can  you help me to fix it 

I don't know why I can't upload the picture here it is attached 

 
 
 
 

 

terryhendicott
21-Topaz II
Mar 2, 2026 12:10 PM UTC

Capture.JPG

 

6 replies

terryhendicott
21-Topaz II
Mar 2, 2026 12:10 PM UTC
15-Moonstone
Mar 2, 2026 12:13 PM UTC

Thanks a lot it works 

Yusra

Translate
23-Emerald I
Mar 2, 2026 12:14 PM UTC

Need to get a little fancy

Translate
15-Moonstone
Mar 2, 2026 12:15 PM UTC

nice thank you

Translate
Werner_E
25-Diamond I
Mar 2, 2026 12:20 PM UTC

A program returns the last expression it executes and in case of your program thats the result of comparing F with 80 kN. So you always get "M36" for any force up to 80 kN.

You may return the vector "size" which you create in your program

grafik.png

But that's probably not what you want to see either.

My crystal ball tells me that you are interested in the first entry that is not 0. So the next largest bolt size. Is that correct?

You could achieve that using the "lookup" function:

grafik.png

The method fails for forces larger than the largest in the list (80kN) because there is no next largest bolt size.

If that's an issue you could cope with that using a "try...onerror..."

grafik.png

BTW, we can easily modify your approach using the for-loop to do the very same. Instead of creating a vector of size values we stop the loop the first time F is smaller or equal than f.y using the "return" statement.

grafik.png

If you don't like using the "return" statement to terminate the program, you may use the "break" statement to terminate just the loop:

grafik.png

 

Translate
15-Moonstone
Mar 2, 2026 12:24 PM UTC

Thank you so much for such explanation 

Translate