function dip = bestdip(rho1, rho2, dips, dist, ht, meas, base); %dip = bestdip(rho1, rho2, dips, dist, ht, meas, base); % computes the Bouguer anomaly assuming a tilted plane of rock lies % below the sediment, dipping towards the closer data points, and % attempts to minimize the anomaly by adjusting the dip of the rock. % rho1 = density of sediment (g/cm^3) % rho2 = density of rock (g/cm^3) % dips = vector of dip angles to test (degrees) % dist = vector of horizontal distances to data points (m) % ht = vector of measured altitudes of data points (m) % meas = vector of measured gravity values (mgal) % base = which row of the vectors is the base station % output is the best apparent dip of rock-sediment interface in degrees err = []; for i = 1:length(dips), err = [err; norm(model2(rho1, rho2, dips(i), dist, ht, meas, base))]; end [e, i] = min(err); dip = dips(i);