How can I calculate the magnitude of n-dimensional vector by Matlab's commands?
97 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mahmood
am 21 Okt. 2012
Bearbeitet: pratyusha adiraju
am 6 Sep. 2016
Is there any specific command for calculating the magnitude of n-dimensional vector?
1 Kommentar
Star Strider
am 21 Okt. 2012
What do you mean by magnitude?
By definition, a vector has only one dimension.
Akzeptierte Antwort
Wayne King
am 21 Okt. 2012
Bearbeitet: Wayne King
am 21 Okt. 2012
I'll assume by "magnitude", you mean the norm. You can just do
norm(x)
but there are different norms with different results
x = randn(10,1);
norm(x,2)
norm(x,1)
norm(x,inf)
So you have to know which one you want. Just
norm(x)
gives the 2-norm by default.
0 Kommentare
Weitere Antworten (1)
Azzi Abdelmalek
am 21 Okt. 2012
v=[2 3 4 5]
ampv=sqrt(v.^2)
1 Kommentar
pratyusha adiraju
am 6 Sep. 2016
Bearbeitet: pratyusha adiraju
am 6 Sep. 2016
magnitude calculation procedure is r = [x y z]
rmag = (x^2 + y^2 + z^2)^0.5
so in matlab rmag =sqrt(sum(r.^2))
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!