cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

min and max function in mathcad

AK_10948685
6-Contributor

min and max function in mathcad

I've attached a snapshot of the Mathcad sheet where I'm working. I need some guidance on how to use the minimum and maximum functions in Mathcad to obtain the FTMF values.

 

AK_10948685_0-1731404000908.png

 

7 REPLIES 7
StuartBruff
23-Emerald III
(To:AK_10948685)

Is the below of any help?

 

Range vectors are useful, but it is generally better to work with vectors.  Your F (which I've renamed vec) is a common user-defined function that converts ranges and matrices into vectors. You'll find it called rng2vec, amongst other things, but the operation of converting matrices into vectors already has the name vec, and it's merely been given an additional Mathcad-specific task.

 

2024 11 12 A.png

 

Stuart

Werner_E
25-Diamond I
(To:AK_10948685)

Instead of creating a range j and then converting it to a vector you could create the vector of angles right ahead.
As Stuart I assumed that you meant the angles to be in degree and added that (pseudo) unit.

Note that Prime assumes angles to be in radiant and also displays angles in radiants unless otherwise told by adding the unit 'deg'.

Vectorization when creating the FTMF vector is not mandatory in your case but this depends on the calculations used and so you are always on the safe side if you apply explicit vectorization when you feed a vector into a scalar function.

Werner_E_1-1731414763342.png

 

Prime 10 sheet attached

 

StuartBruff
23-Emerald III
(To:Werner_E)

I have a set of functions to handle the commonplace tasks of converting range variables to vectors and/or creating additional range variables that will index into vectors or alongside non-integral range variables.   I usually keep them in a (collapsed) Area in my default worksheet.

 

The built-in function format shows a range as a string comprised of either "start..stop" or "start, next..stop" ... but only if it is on the right-hand side of a definition.  If it's on the left-hand side, then Mathcad will iterate through format's argument and apply format to each value in the ranges' sequence.

 

2024 11 12 E.png

 

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Its a really pity that a user-defined function vec`() can't be used the most natural way which would be something like

Werner_E_0-1731425911975.png

Instead we have to define a temporary range variable and must take care how to use it

Werner_E_1-1731426025718.png

 

StuartBruff
23-Emerald III
(To:Werner_E)

Indeed.   There is a bit of a palaver involved in using range operators as arguments to vec or any other function.

 

2024 11 12 F.png

 

Unfortunately, my IsRange function ended up being one of exclusion because one of the standard tests for rangehood (ie, transposition) doesn't work with vec's output.

 

2024 11 12 G.png

 

 

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Yeah, ranges are beasts!

But I am not sure if SMath's way to handle ranges and vectors the same should be the direction to go.

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

Yeah, ranges are beasts!

But I am not sure if SMath's way to handle ranges and vectors the same should be the direction to go.


Oh, I don't know.  It could be amusing.  

 

2024 11 13 A.png

 

2024 11 13 B.png

 

However, the use of ranges (and maybe vectors) for array subscripting is something I'd definitely like to see. 

 

2024 11 13 C.png

 

Indeed, I might very well have requested this capability long ago, back when Sophie and her fellow Stegosaurus stenops were muttering darkly about this new-fangled programming lark Mathcad 7 had foisted upon the Tithonian age, "It'll never catch on", she thought, as she munched on some mossy cycads, paying little heed to the insects madly dashing to escape her ravenous maw, and idly wafting her thagomizer through the air.  "Hah.  Wait until you see what I can do now!", mused a passing Allosaur, "If only there was an IsRange function and the ability to use ranges as array index subranges.".

 

But after all those years learning to deal with the range's,  I think I'd feel rather let down by new users not going through the Range Variable Rite of Initiation.

 

And I'm not sure what the trade offs are for such notation.

 

Stuart

Announcements

Top Tags