The output of my executed code is not giving the answer I am looking for when using the symUnit function

1 visualización (últimos 30 días)
Hello everyone
I am trying to calculate new variables based on defined parameters that use the symUnit function, but the output is not giving me the value based on the defined parameters.
An example:
u=symunit;
f=50 * u.Hz
L=10*10^-3 * u.H
X_L=2*pi*f*L*j
I expected to get a value for X_L and the associated unit, in this case Ohm. However this is the output im getting.

Respuesta aceptada

Paul
Paul el 21 de Feb. de 2021
Editada: Paul el 23 de Feb. de 2021
There are many options to which H*Hz can be converted; which one should be chosen automatically? But you can try it yourself:
>> unitConvert(X_L,u.ohm)
ans =
pi*1i*[Ohm]
If the attemped conversion is invalid, the input is returned unchanged:
>> unitConvert(X_L,u.lumen)
ans =
pi*1i*[H]*[Hz]
  2 comentarios
Benjamin Sørensen
Benjamin Sørensen el 23 de Feb. de 2021
Hello Paul
Thank you for the answer.
I see your point about the unit conversion, and will use the code you have recommended.
Paul
Paul el 23 de Feb. de 2021
Can also force a conversion to derived units if unsure of what unit to convert to:
>> y=5*u.Hz*u.H
y =
5*[H]*[Hz]
>> unitConvert(y,'SI','Derived')
ans =
5*[Ohm]

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by