MATLAB Answers

Magnitude of a vector

2,085 views (last 30 days)
syms x y z
r = [x y z]
rmag???
rmag should equal (x^2 + y^2 + z^2)^0.5
  4 Comments
Abdullraheem Diab
Abdullraheem Diab on 30 Jun 2019
Sqrt(sum(r.^2))

Sign in to comment.

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 5 Sep 2013
Edited: MathWorks Support Team on 22 May 2019
This works perfectly fine on MATLAB R2013a:
>> syms x y z
r = [x y z];
norm(r)
  2 Comments
Bhuvana Krishnaraj
Bhuvana Krishnaraj on 3 Jun 2019
2015.a version >>which sym/nom C:\matlab\toolbox\symbolic\@!sym\norm.m

Sign in to comment.

More Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 5 Sep 2013
m=sqrt(x^2+y^2+z^2)

Tariq Shajahan
Tariq Shajahan on 11 May 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!!

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!