Skip to main content
SPaulis
14-Alexandrite
January 19, 2023
Solved

Matrix Bug? Storing an integer zero in a matrix of mixed items gets returned as a value with unit

  • January 19, 2023
  • 1 reply
  • 3735 views

Mathcad Prime 8.0.0.0.0.0.0

 

So I am trying to store mixed data in a matrix.  It is the only way to pass optional parameters to a user defined function.  One of the parameters I am trying to pass is an integer (in my case representing the number of passes of welds in a welded structure).  But when I supply a zero, my program reads the number as 0•m (or whatever units I set the document to.

 

See the attached Mathcad Prime sheet.  Here is a screenshot if you can't duplicate my error

Screenshot 2023-01-18 205329.png

One possible workaround is to resolve the value this way:  a / SIUnitsOf(a) 

That should strip any value that is in meters of it's unit, but will not work for other units like when Unit System = USCS

Any other suggestions?

Best answer by Werner_E

I don't think that its necessary to ask for different length units  as 0 m= 0 ft = 0 cm ...

 

If your intention is to strip off the unit from any quantity that is zero, regardless of the unit, the following should do he job a swell

Werner_E_1-1674140536792.png

Werner_E_3-1674141051848.png

nj=0 is TRUE even if nj is a zero valued quantity with an attached unit.

1 reply

25-Diamond I
January 19, 2023

Actually I am surprised that Prime adds the unit as (on contrary to Mathcad 14/15) its not using SUC (Static Unit Control) anymore.

Use the predefined "unit" zero instead of 0.

Werner_E_0-1674101872233.png

But note the lowercase "z" as otherwise ...

Werner_E_1-1674101901775.png

Just noticed that pseudounits "rad" and "rev" will do the job as well:

Werner_E_2-1674102070950.png

Werner_E_3-1674102080553.png

 

SPaulis
SPaulis14-AlexandriteAuthor
14-Alexandrite
January 19, 2023

It’s a neat idea @Werner_E  but I do not think it is user friendly enough for most engineers that already struggle with Mathcad.  The user need to input a ‘quantity’ and we engineers are SO used to numbers (no thanks to Excel). 

 

Right now if I test if the number is 0•ft or 0•m, I can catch the bug and report a real zero:

SPauliszyn_0-1674102376940.png

I guess I should add 0•cm for CGS

 

This way the engineer can go ahead and supply an integer quantity of zero.

 

But do you notice in my examples that some situations it is a real zero and others it is 0•m?  Prime should not behave like this--it is too erratic to rely on.  THAT'S IT!!! BACK TO EXCEL!!!

"It's OK to fall in love with your heart, but you design with your head." Omer W. Blodgett
25-Diamond I
January 19, 2023

But do you notice in my examples that some situations it is a real zero and others it is 0•m?


Yes, I did and it looks confusing on first sight. You sure may consider reporting it as a buggy behaviour at PTC support.
On the other hand there is a pattern - whenever the matrix contains a plain number (different from zero) like the 2 or the 1 in your examples, the zero is not "enriched" by a "suitable" unit. I guess the documentation explains that this is exactly the reason for the units/constants "zero" and "Zero" and that they should be used in such cases.

Reasoning is that many user are used to use zeros without units when units are meant. So Prime adds the units if the matrix contains apart from the zeros only quantities with the same unit (strings don't count). When other units or plain numbers are involved, too, Prime can't tell which unit to assign and refrains from doing so.
But I agree that at first glance this behaviour appears inconsistent.

 


Prime should not behave like this--it is too erratic to rely on.

I sure would second that, yes! Prime should take the input as is And if the used means 0 volt or 0 meter must add the unit also when assigning values in a matrix. This would be consistent behaviour.

 


THAT'S IT!!! BACK TO EXCEL!!!

Excel? NO!!! Sure not!!!  Maple, MatLab or, if you have a perpetual licence, real Mathcad (15 or 11). But sure no spreadsheet software! Excel is more danger than help when it comes to engineering projects.