This web page is also available on English. Your browser is configured to use English as the default locale. Would you like to view this page in English? • Yes pleaseNo, thanks

Centro de Scripts y Funciones de Usuario

Algoritmo window para arrays unidimensionales

Esta función usa un algoritmo de ventana para obtener los pesos y fases de cada elemento de un array lineal. Los resultados de la función definen el apuntamiento del array en la dirección dada.

Cmplx[] window(double d, double theta, double phi, int Num, double A, double B, 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 window algorithm to calculate the weights and phases in an unidirectional array of antennas

	double N=Num;										    
	//double A=0.0;
	//double B=1.0;
	double L;									 
	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

	if (N !=1){   //if the numer of elements in the array is different than one
		L=d*(N-1);	
	}
	if (N==1){    //if there is only one element in the array
		L=d*N;
	}

	if (N % 2 ==0){     //if the number of elements in the array is even
		for (int i=1; i<=(N/2); i++){
			a[(N/2)+i-1]=A+B*Math.cos(((d*i)/(L/2))*(Math.PI/2));       //apply the formula of the algorithm to calculate the weigths
		} 
		int cont=N-1;  //initialize cont to N-1
		for (int j=0; j<N/2; j++){
			a[j]=a[cont];  //equate the j element in the array a to the cont element in that same array
			cont=cont-1;   //decrease cont
		}
	}
	if (N % 2 !=0){     //if the number of elements in the array is odd
		for (int i=1; i<=((N+1)/2); i++){
			a[((N-1)/2)+i-1]=A+B*Math.cos(((d*i)/(L/2))*(Math.PI/2));    //apply the formula of the algorithm to calculate the weigths
		} 
		if (N !=1){         //if there is more than one antenna in the array
			int cont=N-1;  //initialize cont to N-1
			for (int j=0; j<=((N-1)/2)-1; j++){
				a[j]=a[cont];  //equate the j element in the array a to the cont element in that same array
				cont=cont-1;   //decrease cont
			}
		}
	}
	                         

	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/window.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

}

¿Te ha sido útil esta información?

Usamos cookies en este sitio web para mejorar tu experiencia al navegar por esta página. Si continúas usando este sitio, aceptas nuestra política de cookies.

Aceptar