function results = function_KalmanFilterData(measures, type, acel, KalmanConfig)
special_case = false;
if(type == 'n')
    type = 'b';
    special_case = true;
end
% Creation of Kalman Filter Results Variable and atribution of time 
results      = zeros(7, size(measures,1));
results(1,:) = measures(:,1);
% Initial Definitions
Pk = eye(6)*(0);
Q = eye(6)*(1);
Rcnt = 1e00;
    if(type == 'i'); R = eye(                 6)*(Rcnt);
elseif(type == 'v'); R = eye(size(measures,2)-1)*(Rcnt);
elseif(type == 'b'); R = eye(size(measures,2)-1)*(Rcnt);
else results = 0; return;
    end

    
% Begin Cycle (Kalman Filter Calculation)
for i = 2:size(results,2)
    % Calculation of time iteration plus definiton of A,B,C and u
    dt = results(1,i)-results(1,i-1);
    A = [1  0  0 dt  0  0
         0  1  0  0 dt  0
         0  0  1  0  0 dt
         0  0  0  1  0  0
         0  0  0  0  1  0
         0  0  0  0  0  1];
    B = [dt^2/2      0      0
              0 dt^2/2      0
              0      0 dt^2/2
             dt      0      0
              0     dt      0
              0      0     dt];
        if(type == 'v'); C = zeros(size(measures,2)-1,6); C(:,2)=1;
    elseif(type == 'i'); C = eye(6);
    elseif(type == 'b'); C1 = eye(6); 
                         C2 = zeros(size(measures,2)-7,6); C2(:,2)=1;
                         C  = [C1; C2];
    else results = 0; return;
        end
    u = [0;0;0];
    % State Prediction
    results(2:7,i) = A*results(2:7,i-1) + B*u;
    % Update
    Gk = Pk*C'*(C*Pk*C'+R)^(-1);
    if(special_case && measures(i,8) == 60140)
         Gk(:,7:end) = 0;   % TRUST IN NULL!!!
    end
    
        if(type == 'v'); results(2:7,i) = results(2:7,i)+(Gk*(measures(i,2:end)'-C*results(2:7,i)));
    elseif(type == 'i'); results(2:7,i) = results(2:7,i)+(Gk*(measures(i,2:end)'-C*results(2:7,i)));
    elseif(type == 'b'); results(2:7,i) = results(2:7,i)+(Gk*(measures(i,2:end)'-C*results(2:7,i)));
    else results = 0; return;
    end
    Pk = A*(eye(6)-Gk*C)*Pk*A'+Q;
end
results = results';
