Skip to main content
14-Alexandrite
March 2, 2026
Solved

How to do this check

  • March 2, 2026
  • 3 replies
  • 226 views

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 

 
 
 
 

 

Best answer by terryhendicott

Capture.JPG

 

3 replies

21-Topaz II
March 2, 2026
14-Alexandrite
March 2, 2026

Thanks a lot it works 

Yusra

23-Emerald I
March 2, 2026

Need to get a little fancy

14-Alexandrite
March 2, 2026

nice thank you

25-Diamond I
March 2, 2026

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

 

14-Alexandrite
March 2, 2026

Thank you so much for such explanation