Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
The READEXCEL command on mathcad prime 4.0 will not transfer over my units in excel. How do I make it read my units or how can I add units?
Excel has no units awareness, so you can't 'read' them in. You can, however, in mathcad multiply whatever you read in by a unit and it will then have that unit attached. If you are reading in a few values that's easy. If it's a matrix, then multiply each column or row by the unit.
Same thing writing out to excel - it won't let you send a unit. So you have to divide everything by the unit you want to get the right numerical value.
Remember - you might be displaying inches or millimeters or whatever - but to mathcad it is stored as the SI unit and only showing you what you ask for. So, you always have to work appropriately with units. Temperatures and angle degrees can be particularly tricky.
Now, if you had A1 = 5 and B1 = m in Excel, there might be a way to get mathcad to recognize that B1 is a unit and that A1*B1 = 5m. But I doubt it.
Here's an example of the effort requred to get units (from an additional excel column) over to Mathcad:
As you can see, most of the work is in the GetUnit() function, and it will be a lot of if-statements if you want to be prepared for all possible units...
Success!
Luc
Additionally to what Luc had written, you have to be aware that a routine like his GetUnit will only work OK with units of the very same dimension - in case of his exemple units of lengths. A Mathcad function unfortunately is not able to return values of different dimensions depending on an input argument.
That depends on the version of Mathcad. In Mathcad 11 and before this is not a problem:
This functionality was broken with Static Unit Checking (Mathcad 12?) and it still is impossible in Mathcad 15 if I'm right. In Prime it's possible again:
The problem in Mathcad 11 (and versions before and after) is that you cannot have mixed units in an array. That's possible in Prime too. This is one of the few areas I think where Prime is superior to Mathcad.
Success!
Luc
Yes, you are right. It was the introduction of SUC which had broken that behavior in the later version of Mathcad.
We don't know if ariperry is using Prime or Mathcad. If he is using Prime, he indeed could use this solution again.
He's using Prime 4 (He complains about the READEXCEL function of Prime 4.0 not transferring units...).
Luc
@LucMeekes wrote:
He's using Prime 4 (He complains about the READEXCEL function of Prime 4.0 not transferring units...).
Luc
Hmm, reading more thoroughly what people are writing really makes things clearer sometimes 🙂
Obvioulsy I was too hasty.
To work seriously with units, you could implement this function in Prime:
You'll need the attached .CSV file with it.
Success!
Luc
Ok, Here's the function for Prime (4.0). It works in Express Prime, thanks to the fact that Prime allows mixed units in an array or matrix.
Success!
Luc
Corrected, the atto's need to be in between the zepto's and the femto's
The Prime file is corrected.
Also added genuine Omega's, next to Ohms.
===> There's an updated version below!
Revisited for a more generic solution.
This should cover all SI units.
The above is to create a UNITS table.
The GetUnit() function definition and a few of its usage examples is below:
And the file attached contains the Prime 4 stuff completely.
Success!
Luc