% sample_rate_and_distance_rate.m
clc
clear

% load variables for given day
load 2014-03-24/monday_24_03.mat;

% gps coordinates of Vienna north-east corner
ne_x = 48.292079905275806;
ne_y = 16.56538598632801;
% gps coordinates of Vienna south-west corner
sw_x = 48.09216946074534;
sw_y = 16.195977050781266;

% define needed variables
sample_rate = 0;
distance_rate = 0;
% counter of samples within GPS boundaries
p = 0;

% loop through the whole data set for the given day
for i = 1:length(m_id)
    
    % check whether the vehicle's gps coordinates are within Vienna region
    if (m_x(i) >= sw_y && m_x(i) <= ne_y) && (m_y(i) >= sw_x && m_y(i) <= ne_x)
        
        % add distance to the cumulative value
        distance_rate = distance_rate + m_meter(i);
        
        % add time interval to the cumulative value
        sample_rate = sample_rate + m_int(i);
        
        % increase counter
        p = p + 1;
        
    end
    
end

% averages
distance_rate/p
sample_rate/p
