1 страниц (16 вхождений)
Is there a way to determine the units of an arbitrary variable - Сообщения
Is there a way to determine the unit attached to an arbitrary variable? I would like to be able to do this in a user defined function.
I tried the most obvious thing x/abs(x) but this gives a dimensionless answer.
Anybody got any ideas?
example for clarification
if x=100V I would like to create a function Units(X) to return V or 1.V
I tried the most obvious thing x/abs(x) but this gives a dimensionless answer.
Anybody got any ideas?
example for clarification
if x=100V I would like to create a function Units(X) to return V or 1.V
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
kevnol 10.03.2016 18:54:00
I am not 100% sure what you are doing Jean but I guess you have abandoned the default unit system and instead you are using your own units which are just unique numbers. Interesting idea but think this system will break down once you introduce compound units (unless you can somehow use prime numbers for basic units). Haven't fully thought it through though.
Davide
When I try to use UoM() in one of my own user defined functions it doesn't seem to work., Any ideas?
I am trying to use UoM to strip the units off a figure
eg StripUnit(x):=x/UoM(x)
x=50V
StripUnit(x)=50V
Or even more simply
Unit(x):=UoM(x)
Unit(50V)=1
When I try to use UoM() in one of my own user defined functions it doesn't seem to work., Any ideas?
I am trying to use UoM to strip the units off a figure
eg StripUnit(x):=x/UoM(x)
x=50V
StripUnit(x)=50V
Or even more simply
Unit(x):=UoM(x)
Unit(50V)=1
1 пользователям понравился этот пост
Davide Carpi 10.03.2016 19:36:00
Try this:

I'm not sure why this is needed.
Brian

I'm not sure why this is needed.
Brian
2 пользователям понравился этот пост
Brian
How do I create a multi line function like that? This looks very useful.
Ahh .. Found it in the programming reference. Fun to be had.
How do I create a multi line function like that? This looks very useful.
Ahh .. Found it in the programming reference. Fun to be had.
Strange behavior, I have to investigate it...
BTW in the Extensions Manager, section Snippets, there is a Snippet called "Operations with units"; if you download it, you can insert the snippet in the canvas typing "Units" and then pressing the TAB key. In this snippet there is a version of UoM made with built-in functions (only for scalars).

BTW in the Extensions Manager, section Snippets, there is a Snippet called "Operations with units"; if you download it, you can insert the snippet in the canvas typing "Units" and then pressing the TAB key. In this snippet there is a version of UoM made with built-in functions (only for scalars).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
Ok ok, I was lost in a glass of water...
UoM was designed to act in a generic way both with symbolic and numeric data... when you use it in a inline function, since x is unknown, his unit is 1 (dimensionless - hold the mouse over the definition); if you want to use it in a inline function you have to use Units(x):UoM(eval(x)). In programming functions (when you use line), eval in the argument is not needed, because the evaluation of UoM(x) is made when you call your function.
![2016-03-11 00_18_01-SMath Studio Desktop - [Page1_].png](/ru-RU/files/Download/XXxbrA/2016-03-11-00_18_01-SMath-Studio-Desktop---[Page1_].png)
Obviously if you know the dimensions the best approach is the one suggested in the post above (#9) by Jean.
UoM was designed to act in a generic way both with symbolic and numeric data... when you use it in a inline function, since x is unknown, his unit is 1 (dimensionless - hold the mouse over the definition); if you want to use it in a inline function you have to use Units(x):UoM(eval(x)). In programming functions (when you use line), eval in the argument is not needed, because the evaluation of UoM(x) is made when you call your function.
![2016-03-11 00_18_01-SMath Studio Desktop - [Page1_].png](/ru-RU/files/Download/XXxbrA/2016-03-11-00_18_01-SMath-Studio-Desktop---[Page1_].png)
Obviously if you know the dimensions the best approach is the one suggested in the post above (#9) by Jean.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
kevnol 10.03.2016 20:37:00
Thank you again David, your input has been very helpful.
The background behind my query is that I use complex number calculations a lot for electrical engineering. Smath handles units well for basic complex number calculations but certain key functions do not work with units (Arg(), Re() and Im()) in particular). You can get around this by dividing off the unit but this looks inelegant and needs to be explained every time I show the work to someone. I hope to write my own user defined functions to replace them and having a UoM() function is a nessecary step.
The background behind my query is that I use complex number calculations a lot for electrical engineering. Smath handles units well for basic complex number calculations but certain key functions do not work with units (Arg(), Re() and Im()) in particular). You can get around this by dividing off the unit but this looks inelegant and needs to be explained every time I show the work to someone. I hope to write my own user defined functions to replace them and having a UoM() function is a nessecary step.
WroteThe background behind my query is that I use complex number calculations a lot for electrical engineering. Smath handles units well for basic complex number calculations but certain key functions do not work with units (Arg(), Re() and Im()) in particular). You can get around this by dividing off the unit but this looks inelegant and needs to be explained every time I show the work to someone. I hope to write my own user defined functions to replace them and having a UoM() function is a nessecary step.
I use lot of complex too. Im(,) Re(,) work well in Smath 5346.
A short example would help to compare.
Jean
Jean here is an example showing what I mean. The functions Re(), Im() and arg() don't work when the operands have units.

By the way you may be interested in the worksheet I did for a simple AC calculation in the complex domain. it is available in the exampls section under "Engineering" and you can see it here: https://smath.com/wiki/GetFile.aspx?File=Examples/ElecEngExample.pdf

By the way you may be interested in the worksheet I did for a simple AC calculation in the complex domain. it is available in the exampls section under "Engineering" and you can see it here: https://smath.com/wiki/GetFile.aspx?File=Examples/ElecEngExample.pdf
There is more than unit problem. I don't use unit
maths are unitless. BUT I append result in "UnitProject".
Years long fight in Mathcad, conclusion from collabs:
"Jean is right". ISO, Engineering ... formulas are given
wrt the unit system. Revisit the "Visual Graphic" example
just reposted this morning.
Jean

maths are unitless. BUT I append result in "UnitProject".
Years long fight in Mathcad, conclusion from collabs:
"Jean is right". ISO, Engineering ... formulas are given
wrt the unit system. Revisit the "Visual Graphic" example
just reposted this morning.
Jean

6 пользователям понравился этот пост
ioan92 12.03.2016 05:58:00, kevnol 11.03.2016 20:34:00, Davide Carpi 11.03.2016 22:09:00, уни 12.03.2016 00:23:00, frapuano 12.03.2016 03:21:00, Radovan Omorjan 12.03.2016 05:47:00
1 страниц (16 вхождений)
-
Новые сообщения
-
Нет новых сообщений