find the magnitude of the vector in matlab

To find the magnitude (also called the length or norm) of a vector in MATLAB, you can use the norm() function. The syntax is as follows:

main.m
magnitude = norm(vector)
25 chars
2 lines

For example, if you have a vector v = [3 4], you can find its magnitude as follows:

main.m
magnitude = norm(v)
20 chars
2 lines

This will return the value 5, which is the length of the vector v.

related categories

gistlibby LogSnag