Home > mfiles > genRandomSatellites.m

genRandomSatellites

PURPOSE ^

SYNOPSIS ^

function satellites = genRandomSatellites( nsats, dist, varargin )

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function satellites = genRandomSatellites( nsats, dist, varargin )
0002     rho = dist;
0003     a = pi/16; b = (7*pi)/16; c = 2*pi;
0004     %% BEGIN randomize satellite locations %%
0005     rand('state',sum(100*clock)); % reset rand to new state
0006     nargs = length(varargin);
0007     if nargs == 0,
0008         phi = a + (b-a).*rand(nsats+1,1);
0009         theta = a + (c-a).*rand(nsats+1,1);
0010     else
0011         % pct = varargin(1);
0012         phi = a + (b-a).*rand(nsats,1); % b/w 0 and pi/2
0013         theta = a + (c-a).*rand(nsats,1); % b/w 0 and 2pi
0014         for k = 2:nsats+1,
0015             phi(k) = 0.975*phi(1) + (phi(1)*0.05)*rand(); % w/i 5% of phi(k-1)
0016             theta(k) = .975*theta(1) + (theta(1)*.05)*rand(); % w/i 5% of theta(k-1)
0017         end 
0018         phi(1) = phi(nsats+1);
0019         theta(1) = theta(nsats+1);
0020     end
0021 
0022     sat = struct( ...
0023         'x', rho*cos(phi(1))*cos(theta(1)), ...
0024         'y', rho*cos(phi(1))*sin(theta(1)), ...
0025         'z', rho*sin(phi(1)), 't', 0 );
0026     for k = 2:nsats,
0027         sat(k).x = rho*cos(phi(k))*cos(theta(k)); 
0028         sat(k).y = rho*cos(phi(k))*sin(theta(k)); 
0029         sat(k).z = rho*sin(phi(k)); 
0030         sat(k).t = 0;
0031     end
0032     %% END randomize satellite locations %%
0033     satellites = sat;
0034 end

Generated on Tue 25-Feb-2014 10:34:45 by m2html © 2005