Maximum Value from Tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Labels:
-
Civil_Engineering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
I typically use ORIGIN:=1 and if you use zero, the range variable will be 0..last(Fp)
“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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you SPauliszyn.
Sorry, I am brand new to MathCAD. At least in relation to most.
How do I use create range?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
“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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Instead of struggling doing all calculation with initially defined vector arguments, you may consider turning your calculations into functions in the varying variables.
That way you later can evaluate these functions for any input variables and compare the results of different inputs side by side
But you still can call these functions vectorized using a vector of input values if its needed
The max values can then be determined either using the aforementioned user-defined function or by single evaluation
You may also consider defining a function which return the max value for any given value of t.
For future questions: its always better to attach the worksheet along with your question!
Prime 10 sheet attached
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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?
“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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
