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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

units of 0

radair
2-Guest

units of 0

During the painful process of trying to get just one of my old files to do something useful in Prime 1.0, I ran across the issue that dynamic units don't even handle some static units cases in mc14. The problem pops up in handling the units of 0. A specific example is:

f(x,y,d) = sqrt((x-d)^2 + y^2)

and trying to evaluate

f(0,0,1*cm) =

which fails with an incompatible units message. while something like 0 + 1*cm = 1*cm runs just fine.

In looking at the units of zero in other worksheets, I see the problem will be more general. The attached worksheet shows the issue with arrays containing 0's mixed in with variables that have units. The mc11 strategy works fine for me, but I could see where people might object to that. Anyone have a better solution for handling 0 (or NaN) mixed in with other Mathcad objects such as scalars with units or text or ...

Robert
3 REPLIES 3

On 8/25/2009 6:09:18 PM, radair wrote:
>while something like 0 + 1*cm
>= 1*cm runs just fine.
>Robert
And what about 0+0�C 😉
I think 0 + 1*cm = Error (as in Mathcad 11 not 14)
Val
http://twt.mpei.ac.ru/ochkov/v_ochkov.htm
RichardJ
19-Tanzanite
(To:radair)

I am OK with the results of M*v and N*v. One has mixed units, the other not.

I agree that the addition of the two matrices should work though, as should the addition of the first two elements of the vector u.

Richard

0+1*cm=1*cm works in mc11 and mc14, but the f(0,0,d)= function call fails in mc11 while it works in mc14. The logic associated with matrices, including extracting 0 from them, doesn't seem consistent to me.

My beef with mixed units in arrays with mc11 was never that matrices and vectors were limited to a single unit, but that there was no way to create tables of objects that were useful for data entry with units or collections of objects that could be used like a structure in c. For data entry, a table might want to have a first row with text headers, a second row with different units for different columns of data and the remaining rows containing normal scalars or possibly nested matrices for easy data extraction. Other collections might mix any combination of text, function pointers, nested arrays, ... for whatever purpose the user had in mind.

The issue I'm running into with 0 in arrays might show up more in programming where I often initialize vector sizes using v[n<-0 and later initialize the individual elements with calls like v[3 = x. Allowing vectors to have more than one unit means I lose a lot of type checking which catches quite a few errors. I'm inclined to want to either tell Mathcad either explicitly in a statement such as M := Table(nrows,ncols) or implicitly by adding non-scalar elements such as string values that the object in question isn't a vector/matrix so allow individual elements to have individual units.

As to making 0 a mutable element when it comes to units, there's the issue of being able to read old Mathcad worksheets along with the clean looking way of initializing sparse arrays with 0 rather than 0*unit where the unit may not be known until run time - a perfect example of dynamic units.

Robert
Announcements

Top Tags