How to get norm (magnitude) of a vector the simple way?
Afficher commentaires plus anciens
I just want to get the norm of
syms phi the;
c = [-cos(phi)*sin(the)^2;-sin(phi)*sin(the)^2; - cos(the)*sin(the)*cos(phi)^2 - cos(the)*sin(the)*sin(phi)^2]
norm(c,2)
isn't really simplifying anything
If I type it manually:
simplify(sqrt(cos(phi)^2*sin(the)^4+sin(phi)^2*sin(the)^4+sin(the)^2*cos(the)^2))
I get a simple answere:
(sin(the)^2)^(1/2)
5 commentaires
Dyuman Joshi
le 5 Mai 2021
Are the and phi symbolic variable?
Niklas Kurz
le 5 Mai 2021
Jan
le 5 Mai 2021
I've tried to let c be a [1x1] to [1x4] vector with inserting some commas in the code. I do not find any combination, where norm( c ) equals (sin(the)^2)^(1/2), which is the same as abs(sin(the)).
Therefore I do not understand, how you simplify what to get this result. Of course norm does not simplify anything, because the purpose of norm() is to calculate a norm. Simplifications are done by simplify().
David Goodmanson
le 6 Mai 2021
Hi Niklas,
If your last two vector elements were
- cos(the)*sin(the)*cos(phi) - cos(the)*sin(the)*sin(phi)
i.e. cos(phi) and sin(phi) not squared, then you would get what you say. But since cos(phi) and sin(phi) are squared, you don't.
Niklas Kurz
le 8 Mai 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Polar Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!