Skip to main content
1-Visitor
July 6, 2010
Question

Vector function

  • July 6, 2010
  • 2 replies
  • 13100 views

Hi

I am trying to create a function which creates a vector and incorporates units, please see attached.

The function currently works, but I want H_units to be calculated automatically if possible, with the user having to input the units.

I have been playing with the parse numerical functions sheet which Stuart posted a while back with little success.

Cheers

Mike

2 replies

19-Tanzanite
July 6, 2010

Sorry, but I'm not sure I understand what you are trying to do. What do each of the arguments to vec_cw_unit represent? What should the calulation of H_units be based on?

1-Visitor
July 6, 2010

Richard

Sorry my explanation us poor.

vec_cw_unit(L,H,H_units_,units) -

L = Low number of the vector (start)

H = High number in the vector (Stop)

H_units = Was added to remove the units from this input, as quite often I would define this above as in the worksheet, but the units have to be removed so the vector can be created.

units = this will define the vector in the chosen unit system.

I might be getting this wrong but I couldn't define the for loop inside the program without removing the units.

1-Visitor
July 8, 2010

I am trying to get my head round what your worksheet "Algo in Program" is achieving.

The reason for the use of Mathcad is becuase of its ability to handle units. If I wanted to work through calculations unitless I could use a Excel or similiar software.

I am trying to get my head round what your worksheet "Algo in Program" is achieving.

The reason for the use of Mathcad is becuase of its ability to handle units. If I wanted to work through calculations unitless I could use a Excel or similiar software.

__________________________________

Mathematics are two things essentially:

1. Scalar

2. Unitless

So is Mathcad = scalar and unitless.

On one side you have the engineering formula(s), unitless c/w the corresponding constants in the system of the originator ... that you first convert if required. Then you carry the entire project unitless and the result is in the "Engineering system of unit" . At this point and only at this point the "Mathcad Unit System" may come into play for your client ... for instance : I read "Hg from the transmitter [the closest unspoiled process variable] ... I apply Jo Blo engineering formula , but my client wants it in MPa ... then just plug the Mathcad "Unit definer" and it converts to MPa.

That is too simple ! In real Engineering life you will be faced with more calculations and functions, functions that may support units [Given/Find] , but also functions that are purely in "scalar unitless" [root]. Mathcad carrying units is only valid in short sequences not involving solvers , that does not go far. More and more, clients/subcontracts have to comply to codes [ISO ....] which you carry as given, i.e: unitless then convert to meet local unit systems like the US imperial.

The "Algo in Program" is the generalised "vector function" . It passes the list of functions, that you can treat internally or simply as a new global function generator that is in discrete mode for the argument. The "sacalar argument" in the list of function is not a scalar argument anymore, but a "discrete argument" . The final data table is unitless, and you convert each column in the "UserUnitSystem" .

If you work in pure physics and use only little functions like integrals, derivatives ... or relationist formulas, you can carry unit [though not needed] . But as soon as you work in Engineering, the formulas are not as pure and simply "engineering algoritms" . What comes out from what you put in is already in the appropriate units, by the design of the algorithm. From °C and P of steam you get the kg/m³. Apart the logical and memory functions, a computing machinery performs no more maths than the 4 AOPS [Arithmetic Operations] +,-,*,/ ,,, besides these 4, your box and no matter how big it is , your box is empty. It just has instructions to collect the right asembly of [+,-,*,/] to get exp(1.234567890987654321).

Keep visiting the "Mathcad Usage", it's where the good stuff is [generally].

jmG

...............................

What's going on ?

It does not want to spell check !

1-Visitor
July 7, 2010

"I am trying to create a function which creates a vector and incorporates units..."

__________________________________

No function creates a vector, the function that creates vector is the function itself,

in which function itself you plug the discretized argument ... multiply by the unit

of your choice = done .

Those things have circulated and circulate regularly.

jmG

1-Visitor
July 7, 2010

jean Giraud wrote

in which function itself you plug the discretized argument ... multiply by the unit

of your choice = done .

I didn't know that M14 didn't have the ability to independently take units away from a variables and that strings cannot be changed into units.

I have stated above in my reply to Richard that my idea seems unachievable and your suggestion seems more valid.

Mike

1-Visitor
July 9, 2010

Mike,

All in all, I think you are lost. Those with unit problem is like this :

==> GrandPa, it's a 2 x3

<== 2 what ? ...

==> Oh ! "meters"

<== 3 what ?

==> ... "cm"

<== How thick ?

==> very thin

<== Yes, but thin like what ?

........................................

Your work sheet was all red 11, what color in 14 ?

It is a lot lot easier to exclude the unit system in the first place, whereas this procedure will accommodate all situations, rather than selecting the cases that work simple. To make it "layman", the unit system is limted to the "toy box", to be quick and practical. Take the cspline qs , no problem to add cm to the X vector and get the work sheet appear done well . NOT SO ! type S = and see the stupid 1/m² appended by the unit system ... S is essentially dimensionless. Next, try to spool the S to file "Must be dimensionless" so how can you spool to file a suite of the project .

In your red work sheet, what was the error message "Units don't match ... must be dimensionless" ? who cares because what is the unit of an index in that little for loop. In the second module "Algo in program", if you can't intoduce the unit system in the indexed loop, you can add it to the data table , fine but check the conversion is OK [I didn't] ... fine so far but can't spool to file. At this very same moment in the community, open the "Optical tweezer", c/w units. Works fine for display ... can't extract the data immediately because not in discrete form ... can't spool to file because of the unit in Z.

Worse is :::

"Now, do a numerical time integration of the force on the particle to get the velocity"

So, what do you get for the velocity ... Z(m) ... velocity is some length/some time.

Next. tabulate the independent variable ... no unit ... How come !

I'm no saying the project is wrong [I have no competence in that] but the resulting applied maths are no further exploitable than display, can't be saved in file . That puts us back to Maths are scalar and unitless, and back on the "Engineer design board" where all formulas are in the appropriate unit system as well as applicable codes. The unit system is usefull for the first time design of some physics, but as soon as proved correct, end of it, redo unitless as an exportable product.

Many collabs love to "band aid" projects with units.

jmG

____________________________

Two renewed problems with this community web:

1. past an unknown size of the compobox, the spell check is OFF.

2. past an unknown size of the compobox, the font formating is OFF.