function [ i ] = last( R )
%LAST(v) returns the index of the last non-null value of the vector.
L = length(R);
for j=0:L-1, 
    i = L - j;
    if R(i) ~= 0
        break
    end
    i = i - 1;
end
