%%@input theta should be a vector of theta values of length numOfSatellites
%%@input phi should be a vector of phi values of length numOfSatellites
function conditionNumber = error_magnification(numOfSatellites,theta,phi)

%%GPS position constants
x = 0;
y = 0;
z = 6370;
c = 299792.458; %speed of light
d = .0001;

%%The position of i satellites
%%Preallocate memory for the array.
satellitePositions = zeros(numOfSatellites,3);

for i = 1:numOfSatellites
    %theta = rand * 2*pi; %rand returns number (0,1)
    %phi = rand * (pi/2);
    mytheta = theta(1,i);
    myphi = phi(1,i);
    satellitePositions(i,:) = getSphericalCoordinates(myphi,mytheta);
end

%%Satellite Ranges
Ri_vector = zeros(numOfSatellites,1); %Ri_vector[i] = Range of satellite i
travel_times = zeros(numOfSatellites,1); %Initialize space travel_times[i] = t_i
for i = 1:numOfSatellites
        Ri_vector(i) = calculateRange(satellitePositions(i,:));
        travel_times(i) = d + Ri_vector(i)/c;
end

%%compute all the different possible travel times
%%There should be 2^(numSatellites) possibilities

%%Travel Times Vector
%%travel_times_change represents all the possible combinations of deltas
%%for any number of satellites.
travel_times_change = generateOnes(numOfSatellites) * 0.0000001;

%%This for loop calculates the Error Magnification Factor for every
%%possible combination of delta_t (+-0.0000001). It only tracks the largest
%%EMF though, overwriting smaller EMF values previously found.
travel_times_row_vector = transpose(travel_times);
bestDeltaT_row = ones(1,numOfSatellites);
difference_in_position_and_emf = 1;
conditionNumber = 1;
for row=1:2^(numOfSatellites)
    travel_times_my_row = (travel_times_row_vector + travel_times_change(row,:));
    x_bar = quadratic_formula(travel_times_my_row,satellitePositions,1);
    y_bar = quadratic_formula(travel_times_my_row,satellitePositions,2);
    z_bar = quadratic_formula(travel_times_my_row,satellitePositions,3);
    d_bar = quadratic_formula(travel_times_my_row,satellitePositions,4);

    delta_x = abs(x-x_bar);
    delta_y = abs(y-y_bar);
    delta_z = abs(z-z_bar);
    infty_norm_xyz = 1; %preallocate the variable

    %determine the max delta position value
    if (delta_x > delta_y && delta_x > delta_z)
        infty_norm_xyz = delta_x;
    elseif (delta_y > delta_x && delta_y > delta_z)
        infty_norm_xyz = delta_y;
    elseif (delta_z > delta_x && delta_z > delta_y)
        infty_norm_xyz = delta_z;
    end
    infty_norm_t = 0.0000001; %This is the max delta_t..But recall all delta_t values will be equal by definition

    infty_norm_xyz = (infty_norm_xyz);
    emf = (infty_norm_xyz)/(infty_norm_t * c);

    %%If this is the first iteration of the loop, then this will be the max
    %%condition number found thus far.
    if (row == 1)
        conditionNumber = emf;
        bestDeltaT = travel_times_change(row,:);
        difference_in_position_and_emf = abs(emf - infty_norm_xyz);
    else
        if(emf > conditionNumber)
            conditionNumber = emf;
            bestDeltaT = travel_times_change(row,:);
            difference_in_position_and_emf = abs(emf - infty_norm_xyz);
        end
    end
end

%%The three variables below are only here to print out the values on the screen.
%%They can be deleted without affecting functionality.
theConditionNumber = conditionNumber %The highest condition number
theGeneratingTrow = bestDeltaT %The delta T's that were used
positionMinusEMF = difference_in_position_and_emf %The greatest difference in position and emf
end
Not enough input arguments.

Error in error_magnification (line 14)
satellitePositions = zeros(numOfSatellites,3);