×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MathCAD 15 - strip variable's units?

MathCAD 15 - strip variable's units?

MathCAD 15 - strip variable's units?

(OP)
I've run into various situations where it would be useful to just simply strip the units off of a variable, so you are only left with the scalar value.

...or even just using a function to check the units of a variable that is already defined.

I've never been able to find anything, but is there a built-in function or a convention for stripping away the units?

RE: MathCAD 15 - strip variable's units?

Could you define a Pscalar quantity after P and manually strip the units off.

P := 100lbf
Pscalar := P/lbf


...but I can't recall if I have ever solved that problem yet.

RE: MathCAD 15 - strip variable's units?

(OP)
I'd like to come up with a more generic function that can work with any variable and any unit...

I just don't know if it's possible...

CODE --> Pseudocode

TruncU (P) := what units does variable "P" have?
If units = lbf Then TruncU (P) = P / lbf If units = psi Then TruncU (P) = P / psi ...

RE: MathCAD 15 - strip variable's units?

When I need a variable to be unitless, I've always found it easier to just divide out the units when I make the equation:


You have to track it on your own, but you'd be doing that anyway with your unit stripping function.

RE: MathCAD 15 - strip variable's units?

The only safe way to "strip units" is to divide by the units manually.

As IRstuff says, you can use the "UnitsOf" function, but it divides by the base units. How would a fully automated solution that strips the units of any / all variables know whether you wanted the scalar answer for a 10 kilogram mass (say) to be given as 0.01 (tonnes), 10 (kg), 10000 (g), 22.046 (pounds) or 352.74 (ounces)?

http://julianh72.blogspot.com

RE: MathCAD 15 - strip variable's units?

(OP)
Wow. I never knew "UnitsOf" was an actual function that existed. It's not exactly what I was hoping for, but it's at least a step in the right direction. Might be able to fudge a useful custom function with it. Neat!

RE: MathCAD 15 - strip variable's units?

P:=2500*lbf

P/UnitsOf(P)returns 1.112 X 10^4 regardless of which Unit System is chosen. Seems to be identical with the SIUnitsOf function.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close