Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
I'd like to implement some form of decibels in Mathcad. I've found a few nice references:
Mathcad Example Using Decibels | Math Encounters Blog
In both of these examples they are creating a forward function dB(x), which works just fine, but also an "inverse function" /dB(x). No matter how I try I cannot get Mathcad Prime to create something that looks like that inverse function. (The CTRL+SHIFT+K approach recommended in the second link doesn't work in Prime.) The closest I've gotten is when I got the Mathcad error message "Unknown error: no_inverse_declared."
Is there any way to create an "inverse function" in Prime?
Solved! Go to Solution.
Here's a Mathcad 15 worksheet that shows how to use dB. I've posted this before (more than once, I think; see here for the original post in a discussion, or argument, about dB: Solved: Re: Working with dB (decibels) - PTC Community). I converted it to Prime, and it doesn't work; it just throws the error you have already seen. So I think you are out of luck. Yet another deficiency in Prime.
One general remark.
We have use dB, pH etc. only in manual calculation. We does not need dB, pH etc. in computer calculation.
And partially 2 pictures from the book Thermal Engineering studies with Excel, Mathcad and Internet
Yes I agree that dB shouldn't be needed for automated calculation, since dB is a shortcut created for easier (human) calculation. But in RF and sonar all of the standard formulas are centered around dB, dBm, dB re 1uPa, etc so it would be nice to be able to use those units within Mathcad.
Here's a Mathcad 15 worksheet that shows how to use dB. I've posted this before (more than once, I think; see here for the original post in a discussion, or argument, about dB: Solved: Re: Working with dB (decibels) - PTC Community). I converted it to Prime, and it doesn't work; it just throws the error you have already seen. So I think you are out of luck. Yet another deficiency in Prime.
The Prime shortcut for special characters is different than Mathcad 15.0 (Ctrl-Shift-K). First, type a double quote (which in 15 gave you text, but not in prime).
""
In between the double quotes, type /dB
"/dB"
Now delete either of the quote marks and follow this variable with a parenthesis to make it a function
/dB( x )
Press : and define the function.
In Mathcad 15, you could make this a postfix operator, but these aren't implemented in Prime yet.
The good news: this trick (using quotes) worked, and I could enter the formula exactly as you said.
The bad news: mathcad still doesn't appear to be treating this as an inverse function; even when I do declare /dB(x) I still get the error no_inverse_declared. Unfortunately I think Richard Jackson hit the nail on the head.
Has this problem been fixed yet? I can find no reference in Help to how to implement an inverse (unit) function.
To move away from discussion about the merits or otherwise of displaying dimensionless units, I have another example - conversion of numbers between bases. I can write a 'unit' function that displays a number as, say, a binary, octal or hex number (well, string, actually). What I'd like to do is use the same name to go from a string to a decimal number (a genuine number, this time).
Cheers,
Stuart
Stuart,
just out of curiosity, I was wondering what your bin/oct/hex conversion functions look like.
Luc
@LucMeekes wrote:
Stuart,
just out of curiosity, I was wondering what your bin/oct/hex conversion functions look like.
Luc
Nothing special, Luc.
Some general-purpose string functions:
Integer to Base conversion functions (number to string😞
Base to Integer conversion functions (string to number😞
I've got another version that works better with str2num ... I'll throw some documentation around it and, hopefully, post it later on today. It's a bit "ragged" though, as it's in development, and uses some vector and string functions that are stepping stones to a more general, Mathcad-oriented, array handling capability.
Cheers,
Stuart
Admittedly your base2num function handles all(?) bases, but did you know that Prime handles a few out of the box:
You MUST precede or start the number with a numerical digit (0...9):
Attached is my implementation of similar functions (Prime 4)
Luc
@LucMeekes wrote:
Admittedly your base2num function handles all(?) bases, but did you know that Prime handles a few out of the box:
You MUST precede the number with a numerical digit (0...9):
Attached is my implementation of similar functions (Prime 4)
Luc
Yes, I did know, thanks, Luc. That's what I was referring to when I said: "I've got another version that works better with str2num". I extended str2num to cope with duodecimal numbers (*) and general bases, the latter being identified by the suffix "bnnn" where nnn is the base (in base 10), and I've also dropped the requirement to have a leading zero. I also amended num2str to work hand-in-hand with str2num by adding a base argument to it - it's a shame we mere users can't define functions with optional arguments. bin, oct, hex, and duo are specialized functions that perform bidirectional conversion, and accept strings with or without the base suffix.
As I said, it's still in development and I'm sure there's a better way to do it. I'll look at your worksheet and see what I can steal ... 😈
Cheers,
Stuart
(*) Now that we're steaming ahead with Brexit, I imagine it won't be long before somebody decides to resurrect the Olde Ways and "bring back our duodecimal-vigesimal monetary system of pounds, shillings, and pence (real pennies, a dozen to the shilling, none of this pandering to the French Europeans and their decimal ways. Hanging's too good for them!)". I'm just getting ahead of the game.
(!@%!# (please imagine the preceding text string is shorthand for impolite words in Russian)). My laptop just expired on me, so I've had to switch to my iMac to complete this response ... I guess I'll have to defer looking at your worksheet until I get my PC laptop back up and running.
... my laptop has an issue with its PSU connection overheating and failing to charge, so I guess I'm going to be digging out the soldering iron at some point. In the meantime, I'm on the backup laptop with its low res screen.
Here's my slightly tidied-up worksheet. I'm still not happy with the conversion functions, but I've got other things vying for my attention, so they'll have to do. Our approaches seem to be similar in strategy but different in tactics.
Leading zeros aren't necessary and I've extended str2num to handles arbitrary bases (up to 35).
Cheers,
Stuart
You can do this (see Prime 4 Express example). It's tedious, but if you really need it:
Sorry for the delay in replying, Fred ... I got sidetracked.
I'm afraid that your suggestion doesn't do what I want, which is to define an inverse function that can be used in a unit placeholder. I get that pesky 'inverse function' error.
I can't access my M15 files (only got Express), but ISTR that even in m15 I had to "cheat" and hack a units XML(?) file to get such f-invf pairs to work properly.
Does anybody know if PTC has any plans to allow users to define their own unit function pairs?
Cheers,
Stuart