Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Translate the entire conversation x

Maximum Value from Tables

MA_11253362
2-Explorer

Maximum Value from Tables

Hello.

 

I have a table that generates two sets of info.

One is the actual design forces, and another is a minimum.

I want the maximum from each case.

For the 8" wall I want it to give me 10 psf and for the 12" wall I'd like it to give me 15 psf.

I have googled but no luck.  I can create a max function but it gives me the maximum of all four numbers.

 

There a way to do this?

MA_11253362_0-1739998991497.png

 

7 REPLIES 7
SPaulis
14-Alexandrite
(To:MA_11253362)

I, like you, commonly make lists/arrays of different elements or scenarios that I want calculating, so I only run through the calculation set only once, not having to duplicate everything for different scenarios/elements. 

 

Where I need to I will use "vectorization" (search it in the Mathcad help file).  

 

But the min/max functions will take all the elements of the arrays/matrices that you throw at it, even if your using "vectorization".  You need to use a range array in order to limit the data that the min/max function have access too:

 

SPauliszyn_2-1740001696137.png

 

 

I typically use ORIGIN:=1 and if you use zero, the range variable will be 0..last(Fp)

 

 

 


  

Shawn P.
“It’s OK to fall in love with your heart. But, when it comes to making engineering decisions, don’t design with your heart.” – Blodgett, Omer W.

Thank you SPauliszyn.

 

Sorry, I am brand new to MathCAD.  At least in relation to most.

 

How do I use create range?

 

MA_11253362_0-1740005000353.png

 

SPaulis
14-Alexandrite
(To:MA_11253362)

Access individual elements on an array or matrix, you need to supply the row and column indexes.  When you press "[" (open square brace) immediately to the right of your variable, and you can enter the row index (for a vertical array) or the "row, column" indexes if a matrix.  So try typing "F", Ctrl-_ (for subscript), "p", "[", and "i" and you will have your variable "Fp" addressed by "i" 

 

You do not need to define "i" twice.  As long as all your input calculations has two values, or as many as the scenarios you are investigating, defining the range array "i" once.  If you have arrays with inconsistent number of elements then... your fired!  

 

You can use any label or name you want for the range variable, but 'mathy' people usually use "i" for rows and "j" for columns.  

 

Search for "about matrices" in your help file.  Mathcad even has a video tutorial there as well. 

Shawn P.
“It’s OK to fall in love with your heart. But, when it comes to making engineering decisions, don’t design with your heart.” – Blodgett, Omer W.

Hi @MA_11253362,

 

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation. 

 

Thanks,
Anurag 

Werner_E
25-Diamond I
(To:MA_11253362)

We cannot vectorize the "max" function directly, but we can vectorize a user-defined function which uses "max". I called it "greatest" in the screenshot below. Name it as you like but try to avoid names of already existing variables or functions (so don't name it "max").

That way you don't have to define range variables which I usually try to avoid unless I really need implicit loops.

Werner_E_0-1740006376484.png

 

Instead of struggling doing all calculation with initially defined vector arguments, you may consider turning your calculations into functions in the varying variables.

Werner_E_0-1740007223742.png

That way you later can evaluate these functions for any input variables and compare the results of different inputs side by side

Werner_E_2-1740007296520.png

But you still can call these functions vectorized using a vector of input values if its needed

Werner_E_3-1740007387878.png

The max values can then be determined either using the aforementioned user-defined function or by single evaluation

Werner_E_4-1740007455043.png

 

You may also consider defining a function which return the max value for any given value of t.

Werner_E_5-1740007774682.png

 

 

For future questions: its always better to attach the worksheet along with your question!

 

Prime 10 sheet attached

SPaulis
14-Alexandrite
(To:Werner_E)

@Werner_E nice work-around.  I knew I could vectorize and user functions, but never took it that extra step to solve the max/min issue.  I supposed I could label it "Max" and "Min" but they will not allow for more input parameters than two or however many are coded into the user function, unless you input the values in an array first.  I too want to avoid defining range variables because it is one extra thing to prove/document.  I guess it's the same for defining a used defined 'max' function.  Either way is still the long way round. 

 

Do you know why max/min functions can't be vectorized?

Shawn P.
“It’s OK to fall in love with your heart. But, when it comes to making engineering decisions, don’t design with your heart.” – Blodgett, Omer W.
Werner_E
25-Diamond I
(To:SPaulis)



Do you know why max/min functions can't be vectorized?


Actually, no. It may be because max/min also natively accept vector arguments, but then vectorization should make clear that we intend to feed the elements singly as scalars into the function.

We have a similar problem with the comparison operators (or is it rather the if-function AND if statement?) which also won't accept vectorization

Werner_E_0-1740071307148.png

 

 

 

 

 

Announcements

Top Tags