%EUSIPCO 2012
%Imperial College London 
%Andriy Gelman, Jon Onativia and Pier Luigi Dragotti 

function signal = compute_variational_direction(direction_list)
%Calculate variational_direction 
if isempty(direction_list)
    direction_list = 0;
end
if length(direction_list) > 2 
    for i = 3:length(direction_list)
        buffer = 45*(direction_list(i) - direction_list(i-1));
        if buffer < -180
            buffer = buffer + 360;
        end
        if buffer > 180
            buffer = buffer -360;
        end
        variational_direction(i) = buffer;
    end
    
    signal = variational_direction(3:end);
    
    
    
else
    signal = [];

end

end
