MATLAB Answers

how to use MATLAB units ?

23 views (last 30 days)
timo on 10 Mar 2016
Edited: Karan Gill on 17 Oct 2017
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
Is there any way to use units beside this hack , which is quite annoying ...

Accepted Answer

Karan Gill
Karan Gill on 10 Mar 2017
Edited: Karan Gill on 17 Oct 2017
Starting R2017a, units are available in MATLAB via Symbolic Math Toolbox. See:
Karan. (Symbolic doc)
[SL: fixed typo.]

More Answers (2)

Walter Roberson
Walter Roberson on 10 Mar 2016
Other than switching to feval() syntax, No.
Walter Roberson
Walter Roberson on 15 Mar 2016
aux1 = feval(symengine, 'unit::convert', 2.1 * V, mV)

Sign in to comment.

timo on 13 Mar 2016
Edited: timo on 14 Mar 2016
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

Community Treasure Hunt

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

Start Hunting!