lettura simple

How to find the length of a vector in Octave

In this lesson I'll explain how to calculate the length of a vector in Octave.

What is the length of a vector? It is the Euclidean length of the vector. It is also called norm. For example, the Euclidean norm of a vector is equal to the length of the arrow.
the length of a vector in space

I'll give you a practical example.

Define a vector in the variable V

>> V=[3 4]
V =
3 4

It is a vector with end point (3;4).


Type the function norm(V) to find the length of the vector (magnitude or norm)

>> norm(V)
ans = 5

The length of the vector (norm) is equal to 5.

It is the length of the arrow in the Cartesian plane.

the lenght of vector is 5

Verify. The length of a vector (modulo) can be calculated using the Pythagorean theorem $$ | \vec{v} | = \sqrt{3^2+4^2} = \sqrt{25} = 5 $$ La lunghezza del vettore è uguale a 5. Il risultato è corretto.

Report a mistake or post a question