how to use MATLAB units ?

I need to use units in Matlab
To use Matlab units i use Mupad like this:
aux1 = evalin(symengine,'unit::convert(2.1*unit::volt, unit::mvolt)')
Which returns
2100.0*unit::mvolt
Is there any way to use units beside this hack , which is quite annoying ...

 Respuesta aceptada

Karan Gill
Karan Gill el 10 de Mzo. de 2017
Editada: Karan Gill el 17 de Oct. de 2017

1 voto

Starting R2017a, units are available in MATLAB via Symbolic Math Toolbox. See:
Karan. (Symbolic doc)
[SL: fixed typo.]

Más respuestas (2)

Walter Roberson
Walter Roberson el 10 de Mzo. de 2016

0 votos

Other than switching to feval() syntax, No.

5 comentarios

timo
timo el 13 de Mzo. de 2016
Can you please elaborate feval() syntax ? Is it shorter ?
Walter Roberson
Walter Roberson el 13 de Mzo. de 2016
V = sym('unit::volt');
mV = sym('unit::mvolt');
aux1 = feval('symengine', 'unit::convert', 2.1 * V, mV)
timo
timo el 14 de Mzo. de 2016
aux1 evaluates wrong
aux1 =
MuPAD symbolic engine
timo
timo el 14 de Mzo. de 2016
Editada: timo el 14 de Mzo. de 2016
Anyway sym syntax is fine by me
I marked my answer as the solution.
Walter Roberson
Walter Roberson el 15 de Mzo. de 2016
aux1 = feval(symengine, 'unit::convert', 2.1 * V, mV)

Iniciar sesión para comentar.

timo
timo el 13 de Mzo. de 2016
Editada: timo el 14 de Mzo. de 2016

0 votos

Well to reduce some extratyping this shall help :)
MUPAD = @(x) sym(x);
Then use like MUPAD('unit::ohm')
The better solution is thanx to Walter's suggestion is to use sym keyword and then the string for Mupad units. I will see how it gets me

Etiquetas

Preguntada:

el 10 de Mzo. de 2016

Editada:

el 17 de Oct. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by