Skip to main content
1-Visitor
July 2, 2024
Question

How do I limit the values in an array in matchad prime 10

  • July 2, 2024
  • 2 replies
  • 1388 views

Hi, i don't speak english but

I want to limit the values in an array

MathCad Prime 10

LP_11025178_0-1719950595622.png

Please help me

2 replies

1-Visitor
July 2, 2024

I want to set the mín value to 4.5 m

18-Opal
July 2, 2024

I don't know if I understood what you are after.

 

But do you want ?

 

 

ppal_0-1719953581605.png

ppal_1-1719953607594.png

 

 

25-Diamond I
July 2, 2024

The expression with the values shown in your screenshot can't be seen in the file your attached.

But using the "min" function should effectively limit the values so all values above 4.5 m are set to 4.5 m

Werner_E_0-1719955463584.png

 

EDIT: Ahh! I just read that you want 4.5 m to be the minimum value. So you should use the "max" function to set all values below 4.5 m to 4.5 m.
As with the values in your sheet all three results are below this threshold, all three are set up to 4.5 m.

Werner_E_1-1719955624686.png

 

Of course you also could use an if-statement

Werner_E_2-1719956053760.png

 

or also the if-function as suggested by ppal

Werner_E_3-1719956082299.png

The local variable "Result" was introduced as otherwise it would have been necessary to use the calculation expression twice, which I considered being harder to read and inefficient.

 

If you need to limit values more often, it might be an option to use a utility function limit(value,hi,lo) which does exactly what the name implies - the value returned will be in the range from lo to hi. This function could be hidden at the top of the sheet in a collapsed region or at the top to the right of the printable page.

It could be implemented using if-statements

Werner_E_4-1719956738984.png

or using the if-function

Werner_E_5-1719956769836.png

or using min and max functions

Werner_E_6-1719956796797.png

 

When you need to use it for a vector of values as in your sheet, you may either use a range variable k

Werner_E_7-1719956866556.png

or you call it vectorized

Werner_E_9-1719956902488.png