Rank: Advanced Member Groups: Registered
Joined: 25/09/2013(UTC) Posts: 325 Location: IL Was thanked: 19 time(s) in 17 post(s)
|
I'm fairly certain this has been discussed before, but I can't seem to find the conversation. I'm trying to remove the units of a variable without changing the value. However, I don't know what the units of the variable are prior to removing them.
For example, say I want to enter L = 1 foot. If I try to remove the units using "UnitsOf" command and dividing then it thinks the units are meters and I will get 0.3048 instead of "1".
Thanks!
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Select all the document ... click Ignore units
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Once you store a variable, everything is converted into base units. To obtain the value for whatever unit, you just divide the variable by that unit. If you want to keep the info about the original unit, you have to store it in a separate variable. |
|
1 user thanked mkraska for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
Originally Posted by: mkraska Once you store a variable, everything is converted into base units. To obtain the value for whatever unit, you just divide the variable by that unit. If you want to keep the info about the original unit, you have to store it in a separate variable. ↑↑↑ This ↑↑↑ Originally Posted by: Jean Giraud Select all the document ... click Ignore units This works only on on direct definitions. e.g. A:3'in [with ignore units on A definition] will be stored as 3 (dimensionless), but B:3'in and then C:B [with ignore units on C definition] won't work. The latter would not help RFreund even if it worked, as data is stored in base units, as mentioned by Martin. Edited by user 24 January 2024 03:20:10(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: Jean Giraud Select all the document ... click Ignore units There are two more options: 1. Construct in silent units. 2. Construct completely units-less. Typical Colebrook Pipe data [T/hr, WC, m/s, kW/hr ...] Everything appropriately instructed. Table header instructed, renders perfect.
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
The question is about how to obtain the value associated to a unit from a variable. Having all dimensionsless avoids the problem, but doesn't answer the question. |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: RFreund For example, say I want to enter L = 1 foot. If I try to remove the units using "UnitsOf" command and dividing then it thinks the units are meters and I will get 0.3048 instead of "1". Like this, silent Units Worksheet84 Silent Unit.sm (5kb) downloaded 2 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 11/01/2018(UTC) Posts: 134 Location: Wisconsin Was thanked: 62 time(s) in 39 post(s)
|
Greetings, Just a few notes of interest: - Functions that extract units:
- UnitsOf() - built in units
- UoM() - built in and Custom units
- Default units:
- SMath doesn't allow you to specify your default unit, but you are able to modify the Units.XML file to redefine what your base units are (*A VERY DELICATE/DETAILED PROCEDURE*)
- Display variable with a different unit then 'default':
- For every output, there is a placeholder to the right of the result (when selected); you can enter your unit of choice into this placeholder and the result will display as if that unit is used.
- You will need to specify for each equation/result which value you want displayed.
- You can create your own custom unit, by default: it is a 'base unit' and will behave as intended.
- You cannot associate it with built-in units, else they will simplify; you will need to keep this unit structure independent of other units.
- UoM() will produce the base-custom unit of your variable.
Therefore: you can create a custom unit of 'FOOT; the variable assigned units of 'FOOT will stay as 'FOOT and UoM() can be used to extract 'FOOT from the variable (however, it will not interact with other units of length as it should. I would not advise taking the 'make everything unitless' as I have found many an error from which units are displayed on result; but to each their own. May this be of Good Help; ⚜ Kenny Lemens, P.E. ᵂᴵ |
|
1 user thanked Kenny Lemens for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.