Skip to main content
1-Visitor
January 31, 2017
Solved

max function applied on matrix/vector with strings gives inconsistent results

  • January 31, 2017
  • 6 replies
  • 2640 views

Please check the sheet attached.

If I use the max-function on a matrix filled with strings, it returns a result.

If I use the same function on a column of the matrix, it gives an error ("These values must all be of one type")

If I assign the column of the matrix to a new variable, but don't evaluate and then use the max function on the new variable it errors

If I assign the column to a new variable and evaluate, then use the max function, it gives a result

If I write a little program and search the max of a column with different values, it errors but in the same program, if I search the max of a column (transpose of a row in this case) with identical values, it doesn't error.

Can anybody explain this inconsistent behaviour?

Best answer by Werner_E

This is really a crazy bug. A simple double transpose of the matrix does the job, too:

So a suitable workaround function could be

Its a pity that we can't create user functions with a variable number of arguments.

6 replies

23-Emerald I
January 31, 2017

Nothing a little brute force can't cure:

25-Diamond I
January 31, 2017

> Can anybody explain this inconsistent behaviour?

No. I would call it a bug and you may report it to PTC.

But you should note that PTC is not really interested in bug reports and so they only offer to do so for paying customers under maintenance - probably just to make them feel better.

tthys1-VisitorAuthor
1-Visitor
February 1, 2017

I can imagine they're not to eager to put time and resources in fixing bugs in Mathcad 15 while they have all that work laying around making Prime look like something decent...

25-Diamond I
January 31, 2017

Here is a workaround for this bug. A new function max for 1 single argument, so you may want to rename it max1 - otherwise you can't use max with more than 1 arguments.

Werner_E25-Diamond IAnswer
25-Diamond I
January 31, 2017

This is really a crazy bug. A simple double transpose of the matrix does the job, too:

So a suitable workaround function could be

Its a pity that we can't create user functions with a variable number of arguments.

tthys1-VisitorAuthor
1-Visitor
February 1, 2017

I think I'll go for this solution, as silly as it looks...