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

What is the difference in units positions in MathCad

YA_10963798
14-Alexandrite

What is the difference in units positions in MathCad

I have a question >> What it is the difference when mathcad write the unit of a resulte inside the brackets [result*Unit] and outside [result]* unit?

YA_10963798_0-1734697237736.png

is there any difference ? and how to make all units showed the same way?

Thanks in advance

Yusra 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:YA_10963798)

If all elements of a vector/matrix are of the same dimension, then Prime uses to place the unit (for all elements) after the matrix and you are also allowed to change this unit to something you like more.

If the matrix contains quantities of different dimensions, Prime places the units right to the values inside the matrix and unfortunately does not allow to change this unit directly. You can write a different unit after the matrix and Prime will change the units inside the matrix accordingly - sometimes with unexpected effects.

In case of nested matrices Prime seems to show units only if all the dimensions in a 'subvector' are the same. Manually editing the unit at the end of the matrix without expanding nested matrices has a strange effect which maybe also could be called a bug...?

Werner_E_0-1734698627913.png

 

 

View solution in original post

11 REPLIES 11
Werner_E
25-Diamond I
(To:YA_10963798)

If all elements of a vector/matrix are of the same dimension, then Prime uses to place the unit (for all elements) after the matrix and you are also allowed to change this unit to something you like more.

If the matrix contains quantities of different dimensions, Prime places the units right to the values inside the matrix and unfortunately does not allow to change this unit directly. You can write a different unit after the matrix and Prime will change the units inside the matrix accordingly - sometimes with unexpected effects.

In case of nested matrices Prime seems to show units only if all the dimensions in a 'subvector' are the same. Manually editing the unit at the end of the matrix without expanding nested matrices has a strange effect which maybe also could be called a bug...?

Werner_E_0-1734698627913.png

 

 

MartinHanak_0-1734702310672.png

 


Martin Hanák
Werner_E
25-Diamond I
(To:MartinHanak)

Yes, that's why I wrote "without expanding" 😉

YA_10963798
14-Alexandrite
(To:Werner_E)

does that affect the results, or just the units?

Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:

does that affect the results, or just the units?


In itself, it is only a representation problem of (nested) matrices. But of course the numbers in the matrix are adjusted accordingly if you change the unit at the back.

StuartBruff
23-Emerald III
(To:YA_10963798)

You also need to be careful if you have NaNs in your results.   A NaN will attract the units of the first element with units in a matrix.   

 

I noticed it in this thread: https://community.ptc.com/t5/Mathcad/Vectorizing-SIUnitsOf-over-array-containing-NaN/m-p/981787/highlight/true#M214833

 

There is a bug report in the system that will hopefully deal with this issue in a (not too distant) future version.

 

I also found that it was commented on in this thread back in January 2023: https://community.ptc.com/t5/Mathcad/Having-fun-with-NaNs-and-mixed-units-in-matrices/m-p/852699/highlight/true#M204913. I was unaware of this thread until I searched for my thread; I also found the '0' problem and that behaviour should also be addressed as part of the same bug report.

 

Stuart

YA_10963798
14-Alexandrite
(To:StuartBruff)

 

@StuartBruff @Werner_E 

 

Yes my results contain NaN >>> I read the thread , but I don't understand how to solve this bug? should I replace NaN with manual zeros ?

YA_10963798_3-1734866702718.png

 

 

I think I'm facing another problem as well

when I use the results in the following calculation mathcade gives an error ( units are not compatible) although all the varibles in that equation are in same unit (MPa)

YA_10963798_0-1734862337671.png

I know I can divide them by their  units  like this: 

YA_10963798_1-1734862448301.png

but this is wrong in engineering ..I can't do that 

 

in previous sheet when all units were represented the same way I didn't get such an error 

YA_10963798_2-1734862737570.png

 

StuartBruff
23-Emerald III
(To:YA_10963798)


@YA_10963798 wrote:

 

@StuartBruff @Werner_E 

 

Yes my results contain NaN >>> I read the thread , but I don't understand how to solve this bug? should I replace NaN with manual zeros ?

YA_10963798_3-1734866702718.png


Hi, Yusra.

 

In this instance, if you haven't explicitly set the NaNs to have units Pa (or kPa), then the bug works for you if you want consistent units, but it should not be relied upon as a future version of Mathcad may change the behaviour.  It's also good practice to set values to the appropriate units (which I know you know!).

 

What would you want to happen?

 


@YA_10963798 wrote:

I think I'm facing another problem as well

when I use the results in the following calculation mathcade gives an error ( units are not compatible) although all the varibles in that equation are in same unit (MPa)

YA_10963798_0-1734862337671.png

I know I can divide them by their  units  like this: 

YA_10963798_1-1734862448301.png

but this is wrong in engineering ..I can't do that 


It's wrong in engineering to not take account of units, but it's not wrong to remove units when needed to support the restrictions imposed by the mathematics or the software.  For example, units might have to be removed to use a trigonometric or exponential function, or a given software function/method might not support units; indeed, many programming languages have no direct support for units.   What would be wrong in the case of Mathcad is not restoring the units after performing such a calculation.

 

Do you have a link to the worksheet that has the problem?

 

Stuart

YA_10963798
14-Alexandrite
(To:StuartBruff)

Hi Stuart 

Sorry for the late reply. 

 

I want to get f2 without the need to divide the varibles in the function by their units ..Is that possible ? it is on page 19 

YA_10963798_0-1734879411633.png

Thanks in advance

 

StuartBruff
23-Emerald III
(To:YA_10963798)

The problem appears to be due to one of the elements having all 43 elements of Mi;c;middle set to all NaNs.  This in turn is down to replacing 0s with NaNs but not giving the NaNs suitable units.

 

2024 12 22 C.png

 

Stuart 

YA_10963798
14-Alexandrite
(To:StuartBruff)

Thank you Stuart , I appreciate your help . 

Announcements

Top Tags