Scripts and User Functions Center

Uniform algorithm for unidimensional arrays

This function uses a uniform algorithm to obtain the weights and phases of each element in a linear array. The results of the function define the pointing of the array in the given direction.

Cmplx[] uniform(double d, double theta, double phi, int Num, int axis) {  //d:element spacing in units of lambda
											                 //theta:beam angle (in degrees)
											               //phi:azimut angle (in degrees)
											               //N:number of array elements
											               //axix:indicates which axis is used-->1 for x axis
											               //                                 -->2 for y axis

//This function uses a uniform algorithm to calculate the weights and phases in an unidirectional array of antennas 											    

	double N=Num;										 
	double[] a=new double[N];   //vector of N elements double type
	double k;
	
	if (axis==1){
		k=(Math.sin(Math.toRadians(theta))*Math.cos(Math.toRadians(phi)));
	}
	if (axis==2){
		k=(Math.sin(Math.toRadians(theta))*Math.sin(Math.toRadians(phi)));
	}
	
	double ang=Math.acos(k);   //ang=arccos(sen(theta)*cos(phi))
	double cose=Math.cos(ang); //cose=cos(ang)
	double ps0=(2*Math.PI*d*cose); //find the phase that we are going to use to direct the array in the desired direction
	
	Cmplx[] z=new Cmplx[N];
	Cmplx[] v=new Cmplx[N];        //vectors of N elements Cmplx type
	double[] y=new double[N];
	double[] fase=new double[N];  //vectors of N elements double type

	for (int i=0; i<N; i++){
		a[i]=1.0;             //fill the N elements vector with ones, which will be the array weigths
	}                          //because we are in a uniform algorithm
	
	for (int n=0; n<N; n++){  
		v[n]=new Cmplx(0,-((n-(N-1)/2)*ps0)); //create a complex vector, with 0 as the real part, where the imaginary part are the
									   //successive phases that we are going to multiply to the weights
								        
		z[n]=Cmplx.mul(a[n],(Cmplx.exp(v[n])));  //find the final result in the form of a complex number by multiplying the weights by the progressive phases, 
		                                         //thus directing the array towards the direction indicated by theta and phi
		                                       
		fase[n]=(Math.atan2(z[n].imag, z[n].real)); //find the phase in radians
		if (fase[n]<0){ // if the phase is less than 0
			fase[n]=2*Math.PI+fase[n]; //add 2*pi
			}
		fase[n]=Math.toDegrees(fase[n]); //find the phase in degrees
		if (fase[n]<0){fase[n]=0.0;}
		
		
		y[n]=(Cmplx.abs(z[n]));  //find the absolute of the complexes, that is, the weights
		
	}
	
	writeFile("./mydatafiles/uniform.txt", y, fase); //write the weigths and phases in a text file
	return z; //return the complex vector z, which contains the results of the algorithm

}

Did you find this information useful?

We use cookies on this website to improve your navigation experience on this site. By using this site, you agree to our cookie policy.

I agree