Removing Units

Removing Units - How to remove units - Сообщения

#1 Опубликовано: 22.01.2024 22:28:49
Ryan Freund

Ryan Freund

19 сообщений из 339 понравились пользователям.

Группа: User

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!
#2 Опубликовано: 22.01.2024 23:10:58
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Select all the document ... click Ignore units
#3 Опубликовано: 23.01.2024 18:36:52
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

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://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
Davide Carpi 23.01.2024 20:48:00
#4 Опубликовано: 23.01.2024 21:18:15
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

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 ↑↑↑

Wrote

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
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 Опубликовано: 24.01.2024 02:23:03
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

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.


#6 Опубликовано: 24.01.2024 15:36:36
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

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 please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Опубликовано: 24.01.2024 19:33:51
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

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 (4 КиБ) скачан 26 раз(а).

#8 Опубликовано: 25.01.2024 23:08:03
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 сообщений из 164 понравились пользователям.

Группа: User

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 BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
1 пользователям понравился этот пост
ioan92 26.01.2024 01:09:00
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений