linterp() with units? - Сообщения
Could it be possible to make linterp() deal with units? here's an example:

and a Mathcad example:

Cheers
Konrad
What do you think about this as a workaround:
[LIVE width=396 height=220]http://smath.info/live/?file=1920[/LIVE]
I think this will do the job most of the time.
Just get rid of the units when you do not need them (by dividing the variable with the appropriate unit). Maybe there might be introduced some function like "UnitsOf" in Mathcad to get rid of them when necessary.
My personal opinion is that it is advisable to avoid using units in some more complicated calculations.
Regards,
Radovan
ЦитатаMy personal opinion is that it is advisable to avoid using units in some more complicated calculations
Yes, I know, sometimes it takes a lot of time to make something work with units, but when I do something without units, the frst thing that happens is the document gets rejected with a comment: please demonstrate the right units have been processed troughout the design. Mind you, Mars Climate Orbiter mission failed because of the units screwed up.
Another thing is, I as a design engineer need some degree of trust in my tools- I do make mistakes and it would be nice when my software warns me about it. Furthermore, I make calculation worksheets for the others, I have to be sure there is some foolproofness in what I give to my younger colleagues. It's not a big problem if it's about the length of my shoe laces, but when it comes to nuclear engineering, it makes the difference.
Regards
Konrad
WroteI could write a C++ program doing my calculations, but I owe you a crate of slivovitsa if it's acceptable to anyone in the chain :-)
I understand your point


WroteMy personal opinion is that it is advisable to avoid using units in some more complicated calculations
WroteYes, I know, sometimes it takes a lot of time to make something work with units, but when I do something without units, the frst thing that happens is the document gets rejected with a comment: please demonstrate the right units have been processed troughout the design. Mind you, Mars Climate Orbiter mission failed because of the units screwed up.
Sorry, I did not make myself understood enough. Let me put it this way. I am not against of using units - contrary I am quite in favor of using them - like many SMath users. This is one of the greatest SMath feature. However, from my own experience with Mathcad I think, and was convinced many times, that when you use units - the safest way is to use them when there are simple algebraic operations where you actually "see" the calculation. Using of units in functions, user defined functions etc. which look like a "black box" is much more dangerous. This way there is a greater chance that something might have been "screwed up". Moreover, this way is much harder to "demonstrate the right units have been processed troughout the design" and to convince some other people about it.
Regarding the example with "linterp" I personally prefer the example given in SMath "live" region than the Mathcad solution. I do not know if this is a matter of taste, matter of clarity or something else. You might disagree and I respect that

Regards,
Radovan
Yes, it is a matter of taste when I do something for myself only, here and now. But let me give you an example. I make a lot of library functions, for general use not only for me. For instance, a function which returns design strength for a given material and temperature, something I tried to do in the first post of this thread. I wrote it in Mathcad so it can handle any temperature units, and it returns stress with units, so you can express it in the units of your choice. You can't fool it. Now imagine the same without units. The user needs to remember that the temperature has to be in deg C and the result in megapascals, not in bars for instance. That's ok, one thing to remember. Now what if there is a hundred of such functions, each of them used dosens of times in various places in the document and there is plenty of such documents which use different input data (from client's spec), which are in different units? I just don't want to have to remember about all this, because I'm sure I will forget one day.
The Mathcad example I gave was just a simplistic, quick check whether it works or not. In my case, I do something like in Smath example I showed in the beginning: a nice table which can be visually checked for errors. And what I like the most in Smath, this table contains reference data with units, which you can't do in Mathcad. It's just one small glitch, linterp() which can't swallow these units :-)ЦитатаI personally prefer the example given in SMath "live" region than the Mathcad solution.
Regards
Konrad
I would like just to mention that almost every intrinsic functions in SMath were made before the units has been implemented. I think that Andrey did his best in order to make the things working after the introduction of units in SMath. As you mentioned "linterp", the three interpolating functions were also introduced before the units implementation.
I hope you would not mind if I just put another example of how to use the functions which are not made to use units. This will not satisfy your wish regarding this subject, but maybe someone will have some benefit from it

[LIVE width=402 height=410]http://smath.info/live/?file=1935[/LIVE]
Regards,
Radovan

Konrad

Regards,
Radovan
-
Новые сообщения
-
Нет новых сообщений