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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

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

SPauliszyn
11-Garnet

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

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

10 REPLIES 10

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

 

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!!!


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.

Well, I meant it to sound like a joke and you got it 🙂


But the sad truth unfortunately, we engineers (at least structural engineers) make gazillion dollars solving a gazillion engineering problems with 'vulgar math' as opposed to 'academic math' (if these term make any sense).  Like, there is a simple shortcut key for partial derivatives, "Ctrl-D", yet no shortcuts for simply changing the number of decimals of results or simple font size +/-.  I don't think there is a single engineer in my company that has ever performed a partial derivative, except in their masters/doctorate classes. 

The real laugh, imho, is when you go to the homepage www.mathcad.com, the first sentence is "Engineering calculations are essential for product design."  They are pushing this on engineers because there is real money there (we have no shortage of work).  But PTC still thinks that the 'academic math' approach is where the money is but it's keeping many engineers stick with Excel.

 

I really really want to like Prime.  It looks great.  But there are so many short comings when it comes to simple vulgar math.  

 

Edit:  Maybe 'accessible math' is a better term for 'vulgar math'

Yeah, Mathcad/Prime could be a great tool, but unfortunately not the way PTC handles the "development".
There will be not much change, though, and so we have to take it as it is or leave it alone.

Too true, too true.  You ain't gonna see that on there website.

 

My latest fix is this:  I broke out the different data into their own lists (turned out simpler with the future calculations) and made a specific test for the different zero unit values:

SPauliszyn_0-1674137624377.png

And I used your idea to specify the zero constant.  The resulting lists are all variables regardless when I change the unit system to any of the three.  My only fear is if rounding errors can possibly creep up with some update so I should also round then check the values.

 

Thanks for the discussion @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.

Even better!  This is a simple fix that I can leave in for good.  Thanks @Werner_E -- you get all the Kudos

so @Werner_E, it seems like Mathcad is working as it is supposed to as per their technical response.    They pointed me to this article:  https://www.ptc.com/en/support/article/cs280864

 

They say it's for legacy calculations but I though Prime was standing on it's own?  Anyway, it's too random of a chance for me to allow mathcad to do whatever it wants for stored values.  I will have to keep testing the results to force it the way I want and always test mathcad results to make sure they make sense.

Considering legacy calculation??

Because of SUC it was not necessary in legacy Mathcad to assign a unit for zero valued quantities.

So a lot of older worksheets fail to work correct just because of this. PTC has dropped SUC (and it wasn't a bad idea doing so) and that way also drop compatibility to legacy sheets in some parts. So It would have been better to consequently demand for units in zero valued quantities and on the other hand also treat a zero without a unit just as that and not adding a unit because Prime thinks that this might be what the user meant.

Top Tags