MATLAB: Are the symbolic units not evaluated by a square root

square rootsymbolicunits

clear, clc
u = symunit;
d = .025*u.m; %Automatically convert to meters
l = .6*u.m;
A = pi*d^2/4;
g = 9.81*u.m/u.s^2;
E = 207e9*u.Pa;
I = pi*d^4/64;
lambda = 76.5e3*u.N/u.m^3;
omega_n = vpa((pi/l)^2*(g*E*I/(A*lambda))^(1/2),4)
When I plug this in, the units stay the same inside the square root.
Why aren't they evaluated?

Best Answer

  • It appears that the square root is still expressed as a square root, so the units remain the same within it:
    omega_n =
    Doing this:
    [omega_n,omega_n_u] = separateUnits(omega_n)
    produces this:
    omega_n =
    omega_n_u =
    So the units convert correctly. It is necessary to specifically request the conversion.