Magnitude of a vector with unit

1 vue (au cours des 30 derniers jours)
RH
RH le 12 Mar 2023
Commenté : RH le 12 Mar 2023
I am having a trouble getting the numerical value of the magnitude of a vector with a unit.
clearvars;
u=symunit;
x=[1 2 3]*(u.m);
norm(x)
ans = 
x=[1 2 3];
norm(x)
ans = 3.7417
x=[1 2 3]*(u.m);
y=[5 6 7]*(u.m);
z=norm(x)/norm(y)
z = 
vpa(z)
ans = 
As it can be seen above, Matlab does not give me the numerical value of the magnitude when units are present.

Réponse acceptée

Paul
Paul le 12 Mar 2023
Looks like simplify pulls the unit^2 out of the root
u=symunit;
x=[1 2 3]*(u.m);
norm(x)
ans = 
simplify(norm(x))
ans = 
vpa(ans)
ans = 
x=[1 2 3]*(u.m);
y=[5 6 7]*(u.m);
z=simplify(norm(x)/norm(y))
z = 
  1 commentaire
RH
RH le 12 Mar 2023
Thanks!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by