function maxerror = testsats(M)
X = [0;0;6370;.0001];
R = ones(size(M,1),1);
T = ones(size(M,1),1);
maxerror = 0;
tcheck = zeros(size(M,1),1);
tchange = ones(size(M,1),1);
for i = 1:size(M,1)
    tx = M(i,1)*cos(M(i,2))*cos(M(i,3));
    ty = M(i,1)*cos(M(i,2))*sin(M(i,3));
    tz = M(i,1)*cos(M(i,2));
    R(i) = sqrt((tx-X(1))^2 + (ty-X(2))^2 + (tz-X(3))^2);
    T(i) = X(4) + R(i)/299792.458;
end
for i = 1:3^size(M,1)
    for j = 1:size(M,1)
        tchange(j) = (1 - mod(floor((i-1)/3^(j-1)),3))*1e-8;
    end
    %tchange = t(i,size(M,1))*1e-8;
    x0 = getlocation([M T+tchange],1);
    if tchange ~= tcheck
        temperror = norm(X-x0,Inf)/(299792.458*norm(tchange,Inf));
    else
        temperror = 0;
    end
    if temperror > maxerror
        maxerror = temperror;
    end
end