Magnitude of a vector
2.632 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Philosophaie
il 5 Set 2013
Commentato: Steven Lord
il 11 Mar 2023
syms x y z
r = [x y z]
rmag???
rmag should equal (x^2 + y^2 + z^2)^0.5
4 Commenti
Risposta accettata
Shashank Prasanna
il 5 Set 2013
Modificato: MathWorks Support Team
il 22 Mag 2019
This works perfectly fine on MATLAB R2013a:
>> syms x y z
r = [x y z];
norm(r)
2 Commenti
Shashank Prasanna
il 5 Set 2013
Modificato: MathWorks Support Team
il 22 Mag 2019
What version of MATLAB are you using? Can you confirm that you see the file when you run this:
>> which sym/norm
Bhuvana Krishnaraj
il 3 Giu 2019
2015.a version >>which sym/nom C:\matlab\toolbox\symbolic\@!sym\norm.m
Più risposte (2)
Tariq Shajahan
il 11 Mag 2015
if 'r' is a vector. norm(r), gives the magnitude only if the vector has values. If r is an array of vectors, then the norm does not return the magnitude, rather the norm!!
2 Commenti
John D'Errico
il 11 Mar 2023
If r is an array of vectors, what would you expect? How does MATLAB know, for example, that you want to compute the norm of each row of an array, as opposed to a matrix norm? In fact, when MATLAB is given a double precision array, and you use norm, it computes the MATRIX norm.
A = magic(5)
norm(A)
There is no reason to expect it should instead compute the norm of each row, or each column. That would be wrong.
norm(sym(A))
And norm is able to do the same thing for a symbolic array. So there should be no surprise here.
Steven Lord
il 11 Mar 2023
Vedere anche
Categorie
Scopri di più su Linear Algebra in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!