How can I calculate the magnitude of n-dimensional vector by Matlab's commands?
조회 수: 112 (최근 30일)
이전 댓글 표시
Is there any specific command for calculating the magnitude of n-dimensional vector?
댓글 수: 1
Star Strider
2012년 10월 21일
What do you mean by magnitude?
By definition, a vector has only one dimension.
채택된 답변
Wayne King
2012년 10월 21일
편집: Wayne King
2012년 10월 21일
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
추가 답변 (1개)
Azzi Abdelmalek
2012년 10월 21일
v=[2 3 4 5]
ampv=sqrt(v.^2)
댓글 수: 1
pratyusha adiraju
2016년 9월 6일
편집: pratyusha adiraju
2016년 9월 6일
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))
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!