Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline RFreund  
#1 Posted : 23 January 2024 04:28:49(UTC)
RFreund


Rank: Advanced Member

Groups: Registered
Joined: 25/09/2013(UTC)
Posts: 325
United States
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!

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 23 January 2024 05:10:58(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Select all the document ... click Ignore units
Offline mkraska  
#3 Posted : 24 January 2024 00:36:52(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

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.
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 24/01/2024(UTC)
Offline Davide Carpi  
#4 Posted : 24 January 2024 03:18:15(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1331 time(s) in 876 post(s)
Originally Posted by: mkraska Go to Quoted Post
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 Go to Quoted Post
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.

2024-01-23 14_20_12-SMath Solver - [Worksheet1_].png

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
Offline Jean Giraud  
#5 Posted : 24 January 2024 08:23:03(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
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.


Offline Davide Carpi  
#6 Posted : 24 January 2024 21:36:36(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
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
Offline Jean Giraud  
#7 Posted : 25 January 2024 01:33:51(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: RFreund Go to Quoted Post
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).

Offline Kenny Lemens  
#8 Posted : 26 January 2024 05:08:03(UTC)
Kenny Lemens


Rank: Advanced Member

Groups: Registered
Joined: 11/01/2018(UTC)
Posts: 134
Man
United States
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. ᵂᴵ
"No matter where you go, there you are." -Buckaroo Banzai

Hotkeys: https://en.smath.com/for...rce.ashx?a=45771&b=2
thanks 1 user thanked Kenny Lemens for this useful post.
on 26/01/2024(UTC)
Users browsing this topic
Guest
Similar Topics
Removing units from a result / variable (Questions)
by zigoreto 31/01/2020 14:10:12(UTC)
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.