back

Solution to exercise 3.1.2

In order to normalize a vector we have to calculate its length. It can be using the function norm(). <sxh c>

  function y = normalize(x)
     L = norm(x);
     y = x/L; 
  endfunction

</sxh>

Variables x and y are vector variables. Please note how vector and scalar operands are handled for division operator on line 3.

  • en/teaching/subjects/it/labs/sol_3_1_2.txt
  • Last modified: 2017/10/02 15:54
  • (external edit)