Magnitude of a vector
조회 수: 2,706 (최근 30일)
이전 댓글 표시
syms x y z
r = [x y z]
rmag???
rmag should equal (x^2 + y^2 + z^2)^0.5
댓글 수: 4
채택된 답변
Shashank Prasanna
2013년 9월 5일
편집: MathWorks Support Team
2019년 5월 22일
This works perfectly fine on MATLAB R2013a:
>> syms x y z
r = [x y z];
norm(r)
댓글 수: 2
Shashank Prasanna
2013년 9월 5일
편집: MathWorks Support Team
2019년 5월 22일
What version of MATLAB are you using? Can you confirm that you see the file when you run this:
>> which sym/norm
Bhuvana Krishnaraj
2019년 6월 3일
2015.a version >>which sym/nom C:\matlab\toolbox\symbolic\@!sym\norm.m
추가 답변 (2개)
Tariq Shajahan
2015년 5월 11일
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
John D'Errico
2023년 3월 11일
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
2023년 3월 11일
A = magic(5);
vecnorm(A, 2, 1) % default 2-norm in dimension 1
vecnorm(A, 1, 2) % 1-norm in dimension 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!