apÉndice: cÓdigo fuente de scilab ... -...

48
APÉNDICE: CÓDIGO FUENTE DE SCILAB APÉNDICE CÓDIGO FUENTE DE SCILAB function principal() //cuerpo principal del programa. Presenta al usuario cuatro interfaces gráficas en las que //podrá ir eligiendo los parámetros que quiera que tenga el radioenlace. xUTM=[276:295]; yUTM=[4061:4075]; // xUTM e yUTM son las dimensiones del mapa topográfico. cv=[280 340 240 300 380 310 560 870 980 960 800 620 720 820 960 1100 960 1060 1420 940;... 260 500 460 420 340 380 400 780 1060 1080 1040 820 720 880 800 960 1180 1190 1140 1240;... 310 380 680 680 460 440 560 700 820 820 970 1010 920 900 840 800 960 1160 1100 1080;... 300 560 640 700 440 460 620 650 860 1140 1200 820 880 930 820 820 940 1060 940 940;... 360 720 560 420 440 540 700 780 900 1010 1180 1300 940 1020 900 840 960 1090 930 1040;... 310 580 500 490 510 410 510 870 820 1020 1070 1200 1060 860 950 860 900 1100 1000 960;... 260 300 340 290 510 420 570 930 1040 1020 1200 1320 1340 1140 830 950 840 850 910 970;... 300 320 350 330 420 360 590 870 1000 1180 1160 1430 1360 1100 840 840 820 880 970 930;... 280 640 480 420 540 710 640 680 770 1040 1240 1430 1270 1140 850 820 810 860 940 960;... 280 400 780 890 740 640 690 750 760 860 1120 1260 1060 1240 820 830 880 790 910 840;... 260 420 730 700 550 660 800 1040 1180 1130 1220 1000 960 860 700 800 800 840 800 820;... 360 320 520 570 440 660 1180 1370 1350 1140 1240 1230 970 990 840 610 650 710 760 830;... 340 280 480 540 680 560 860 970 920 840 820 1100 1060 710 640 630 470 560 620 650;... 360 380 490 690 1060 720 900 1240 1040 760 870 1300 1180 880 640 460 440 580 500 490;... 360 420 500 720 980 900 1010 910 1100 760 760 800 1000 1140 1020 580 500 530 490 650]; cv=cv'; //mapa topográfico de la zona. //se crea la primera interfaz gráfica de usuario o pantalla 1. f1 = figure(1, "Position", [50 50 225 600],... "BackgroundColor", [0.9 0.9 0.9],... "Unit", "pixel"); m=uimenu(f1,'label', 'Menú'); m1=uimenu(m,'label', 'Cerrar Figura', 'callback', "fin=%t;"); m2=uimenu(m,'label', 'Cerrar scilab', 'callback', "exit"); fr1= uicontrol(f1, "Position" , [15 370 195 210],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); fr2= uicontrol(f1, "Position" , [15 80 195 210],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); t1 = uicontrol(f1, "Position" , [15 580 190 10],... "Style" , "text",... "String" , "PARÁMETROS DE ENTRADA",... "fontsize" , 10,... "horizontalalignment","left",... "BackgroundColor",[0.9 0.9 0.9]); t2 = uicontrol(f1, "Position" , [25 540 120 20],... "Style" , "text",... "String" , "Frecuencia (MHz):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t3 = uicontrol(f1, "Position" , [25 510 120 20],... 112

Upload: others

Post on 27-Jun-2020

28 views

Category:

Documents


0 download

TRANSCRIPT

APÉNDICE: CÓDIGO FUENTE DE SCILAB

APÉNDICE

CÓDIGO FUENTE DE SCILAB

function principal() //cuerpo principal del programa. Presenta al usuario cuatro interfaces gráficas en las que //podrá ir eligiendo los parámetros que quiera que tenga el radioenlace. xUTM=[276:295]; yUTM=[4061:4075]; // xUTM e yUTM son las dimensiones del mapa topográfico. cv=[280 340 240 300 380 310 560 870 980 960 800 620 720 820 960 1100 960 1060 1420 940;... 260 500 460 420 340 380 400 780 1060 1080 1040 820 720 880 800 960 1180 1190 1140 1240;... 310 380 680 680 460 440 560 700 820 820 970 1010 920 900 840 800 960 1160 1100 1080;... 300 560 640 700 440 460 620 650 860 1140 1200 820 880 930 820 820 940 1060 940 940;... 360 720 560 420 440 540 700 780 900 1010 1180 1300 940 1020 900 840 960 1090 930 1040;... 310 580 500 490 510 410 510 870 820 1020 1070 1200 1060 860 950 860 900 1100 1000 960;... 260 300 340 290 510 420 570 930 1040 1020 1200 1320 1340 1140 830 950 840 850 910 970;... 300 320 350 330 420 360 590 870 1000 1180 1160 1430 1360 1100 840 840 820 880 970 930;... 280 640 480 420 540 710 640 680 770 1040 1240 1430 1270 1140 850 820 810 860 940 960;... 280 400 780 890 740 640 690 750 760 860 1120 1260 1060 1240 820 830 880 790 910 840;... 260 420 730 700 550 660 800 1040 1180 1130 1220 1000 960 860 700 800 800 840 800 820;... 360 320 520 570 440 660 1180 1370 1350 1140 1240 1230 970 990 840 610 650 710 760 830;... 340 280 480 540 680 560 860 970 920 840 820 1100 1060 710 640 630 470 560 620 650;... 360 380 490 690 1060 720 900 1240 1040 760 870 1300 1180 880 640 460 440 580 500 490;... 360 420 500 720 980 900 1010 910 1100 760 760 800 1000 1140 1020 580 500 530 490 650]; cv=cv'; //mapa topográfico de la zona. //se crea la primera interfaz gráfica de usuario o pantalla 1. f1 = figure(1, "Position", [50 50 225 600],... "BackgroundColor", [0.9 0.9 0.9],... "Unit", "pixel"); m=uimenu(f1,'label', 'Menú'); m1=uimenu(m,'label', 'Cerrar Figura', 'callback', "fin=%t;"); m2=uimenu(m,'label', 'Cerrar scilab', 'callback', "exit"); fr1= uicontrol(f1, "Position" , [15 370 195 210],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); fr2= uicontrol(f1, "Position" , [15 80 195 210],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); t1 = uicontrol(f1, "Position" , [15 580 190 10],... "Style" , "text",... "String" , "PARÁMETROS DE ENTRADA",... "fontsize" , 10,... "horizontalalignment","left",... "BackgroundColor",[0.9 0.9 0.9]); t2 = uicontrol(f1, "Position" , [25 540 120 20],... "Style" , "text",... "String" , "Frecuencia (MHz):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t3 = uicontrol(f1, "Position" , [25 510 120 20],...

112

APÉNDICE: CÓDIGO FUENTE DE SCILAB

"Style" , "text",... "String" , "Potencia Tx (dBw):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t4 = uicontrol(f1, "Position" , [25 480 120 20],... "Style" , "text",... "String" , "Ganancia Tx (dB):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t5 = uicontrol(f1, "Position" , [25 450 120 20],... "Style" , "text",... "String" , "Ganancia Rx (dB):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t6 = uicontrol(f1, "Position" , [25 250 120 20],... "Style" , "text",... "String" , "xTx:",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t7 = uicontrol(f1, "Position" , [25 220 120 20],... "Style" , "text",... "String" , "yTx:",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t8 = uicontrol(f1, "Position" , [25 190 120 20],... "Style" , "text",... "String" , "xRx:",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t9 = uicontrol(f1, "Position" , [25 160 120 20],... "Style" , "text",... "String" , "yRx:",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t10 = uicontrol(f1, "Position" , [25 130 120 20],... "Style" , "text",... "String" , "Distancia (Km):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t11 = uicontrol(f1, "Position" , [25 90 160 40],... "Style" , "text",... "String" , "Las coordenadas corresponden\na la cuadrícula kilométrica U.T.M.",... "fontsize" , 11,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t12 = uicontrol(f1, "Position" , [130 250 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]);

113

APÉNDICE: CÓDIGO FUENTE DE SCILAB

t13 = uicontrol(f1, "Position" , [130 220 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t14 = uicontrol(f1, "Position" , [130 190 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t15 = uicontrol(f1, "Position" , [130 160 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t16 = uicontrol(f1, "Position" , [130 130 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); e1 = uicontrol(f1, "Position" , [150 540 50 20],... "Style" , "edit",... "String" , "",... "BackgroundColor",[1 1 1]); e2 = uicontrol(f1, "Position" , [150 510 50 20],... "Style" , "edit",... "String" , "",... "BackgroundColor",[1 1 1]); e3 = uicontrol(f1, "Position" , [150 480 50 20],... "Style" , "edit",... "String" , "",... "BackgroundColor",[1 1 1]); e4 = uicontrol(f1, "Position" , [150 450 50 20],... "Style" , "edit",... "String" , "",... "BackgroundColor",[1 1 1]); b1 = uicontrol(f1, "Position" , [80 400 120 40],... "Style" , "pushbutton",... "String" , "CAPTURAR DATOS",... "FontWeight", "bold",... "callback" , "nueva_captura()" ,... "BackgroundColor",[0.5 0.7 0.9]); r1 = uicontrol(f1, "Position" , [140 374 60 20],... "Style" , "radiobutton",... "String" , "Hecho",... "horizontalalignment","right",... "FontWeight", "bold",... "BackgroundColor",[0.5 0.7 0.9]); fin=%f; inicurvas=%t; iniperfil=%t; buttondialog("Por favor, introduzca los parámetros de entrada requeridos.","OK","info"); while ~fin then sleep(1) if get(r1,'value')==1&inicurvas then b2 = uicontrol(f1, "Position" , [30 310 160 40],... "Style" , "pushbutton",... "String" , "TRAZAR CURVAS DE NIVEL",... "FontWeight", "bold",...

114

APÉNDICE: CÓDIGO FUENTE DE SCILAB

"callback" , "curvas_de_nivel(xUTM,yUTM,cv)" ,... "BackgroundColor",[0.5 0.7 0.9]); inicurvas=%f; end if get(t16,'string')<>''&iniperfil then b3 = uicontrol(f1, "Position" , [40 20 140 40],... "Style" , "pushbutton",... "String" , "PERFIL DEL TERRENO",... "FontWeight", "bold",... "callback" , "fin=%t;" ,... "BackgroundColor",[0.5 0.7 0.9]); iniperfil=%f; end lab=findobj('label', 'Menú'); if lab==[] then return; end end fMHz=eval(get(e1,"string")); potTx=eval(get(e2,"string")); Gt=eval(get(e3,"string")); Gr=eval(get(e4,"string")); xTx=eval(get(t12,"string")); yTx=eval(get(t13,"string")); xRx=eval(get(t14,"string")); yRx=eval(get(t15,"string")); dKm=eval(get(t16,"string")); Gtstr=string(Gt); Grstr=string(Gr); disp('Frecuencia (MHz):') disp(fMHz) disp('Potencia transmitida (dBW):') disp(potTx) disp('Ganancia de transmisión (dB):') disp(Gt) disp('Ganancia de recepción (dB):') disp(Gr) disp('abscisa del transmisor (UTM kilométrica):') disp(xTx) disp('Ordenada del transmisor (UTM kilométrica):') disp(yTx) disp('abscisa del receptor (UTM kilométrica):') disp(xRx) disp('Ordenada del receptor (UTM kilométrica):') disp(yRx) disp('Distancia del radioenlace (Km):') disp(dKm) close(f1); //se cierra la primera interfaz gráfica de usuario. xdel(); //se borra la actual ventana gráfica. pantalla2=%t; while pantalla2 then //se crea la pantalla 2. f2 = figure(2,"Position",[50 50 325 600],... "BackgroundColor",[0.9 0.9 0.9],... "Unit", "pixel"); m=uimenu(f2,'label', 'Menú'); m1=uimenu(m,'label', 'Cerrar Figura', 'callback', "respuesta=%t;"); m2=uimenu(m,'label', 'Cerrar scilab', 'callback', "exit");

115

APÉNDICE: CÓDIGO FUENTE DE SCILAB

fr1= uicontrol(f2, "Position" , [5 510 210 70],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); fr2= uicontrol(f2, "Position" , [5 380 315 90],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); fr3= uicontrol(f2, "Position" , [5 250 210 70],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); fr4= uicontrol(f2, "Position" , [5 80 315 130],... "Style" , "frame",... "BackgroundColor",[0.5 0.3 0.9]); t1 = uicontrol(f2, "Position" , [10 550 120 20],... "Style" , "text",... "String" , "Frecuencia (MHz):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t2 = uicontrol(f2, "Position" , [10 520 120 20],... "Style" , "text",... "String" , "Distancia (Km):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t3 = uicontrol(f2, "Position" , [10 430 120 20],... "Style" , "text",... "String" , "Altura mástil Tx (m):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t4 = uicontrol(f2, "Position" , [10 400 120 20],... "Style" , "text",... "String" , "Altura mástil Rx(m):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t5 = uicontrol(f2, "Position" , [15 290 120 20],... "Style" , "text",... "String" , "Altura máxima (m):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t6 = uicontrol(f2, "Position" , [15 260 120 20],... "Style" , "text",... "String" , "Altura mínima (m):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t7 = uicontrol(f2, "Position" , [140 550 65 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t8 = uicontrol(f2, "Position" , [140 520 65 20],... "Style" , "text",... "String" , "",...

116

APÉNDICE: CÓDIGO FUENTE DE SCILAB

"BackgroundColor",[0.55 0.75 0.95]); t9 = uicontrol(f2, "Position" , [140 290 65 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t10 = uicontrol(f2, "Position" , [140 260 65 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t11 = uicontrol(f2, "Position" , [15 180 220 20],... "Style" , "text",... "String" , "Potencia transmitida (dBw):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t12 = uicontrol(f2, "Position" , [15 150 220 20],... "Style" , "text",... "String" , "Pérdida básica por propagación (dB):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t13 = uicontrol(f2, "Position" , [15 120 220 20],... "Style" , "text",... "String" , "Pérdida en obstáculos (dB):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t14 = uicontrol(f2, "Position" , [15 90 220 20],... "Style" , "text",... "String" , "Potencia actual recibida (dBw):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t15 = uicontrol(f2, "Position" , [240 180 65 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t16 = uicontrol(f2, "Position" , [240 150 65 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t17 = uicontrol(f2, "Position" , [240 120 65 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t18 = uicontrol(f2, "Position" , [240 90 65 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t19 = uicontrol(f2, "Position" , [5 470 320 20],... "Style" , "text",... "String" , "ALTURA DE LOS MÁSTILES",... "fontsize" , 10,... "horizontalalignment", "left",... "BackgroundColor",[0.9 0.9 0.9]);

117

APÉNDICE: CÓDIGO FUENTE DE SCILAB

t20 = uicontrol(f2, "Position" , [5 210 150 20],... "Style" , "text",... "String" , "BALANCE DE POTENCIAS",... "fontsize" , 10,... "horizontalalignment", "left",... "BackgroundColor",[0.9 0.9 0.9]); e1 = uicontrol(f2, "Position" , [140 430 65 20],... "Style" , "edit",... "String" , "",... "BackgroundColor",[1 1 1]); e2 = uicontrol(f2, "Position" , [140 400 65 20],... "Style" , "edit",... "String" , "",... "BackgroundColor",[1 1 1]); r1 = uicontrol(f2, "Position" , [225 390 90 20],... "Style" , "radiobutton",... "String" , "Hecho",... "horizontalalignment","right",... "FontWeight", "bold",... "BackgroundColor",[0.5 0.7 0.9]); b1 = uicontrol(f2, "Position" , [215 420 100 40],... "Style" , "pushbutton",... "String" , "Capturar datos",... "FontWeight", "bold",... "callback" , "nueva_captura2()" ,... "BackgroundColor",[0.5 0.7 0.9]); fMHzstr=string(fMHz); dKmstr=string(dKm); potTxstr=string(potTx); set(t7,"string",fMHzstr); set(t8,"string",dKmstr); set(t15,"string",potTxstr); lambdam=300/fMHz; altmastilmin=5*lambdam; fin=%f; iniperfil=%t; empezar=%f; mastiles=%f; terminar=%f; aobstcalculada=%t; continuar=%f; respuesta=%f; buttondialog("Por favor, introduzca las alturas de los mástiles de las antenas de transmisión y recepción.","OK","info"); //pide la introducción de las alturas de los mástiles sólo la primera vez que se ejecuta la pantalla 2. while ~fin then sleep(1) lab=findobj('label', 'Menú'); if lab==[] then return; end if get(r1,'value')==1&iniperfil then ht=eval(get(e1,"string")); hr=eval(get(e2,"string")); disp('Altura del mástil de transmisión (m):') disp(ht) disp('Altura del mástil de recepción (m):') disp(hr) b2 = uicontrol(f2, "Position" , [70 330 180 40],...

118

APÉNDICE: CÓDIGO FUENTE DE SCILAB

"Style" , "pushbutton",... "String" , "TRAZAR PERFIL DEL TERRENO",... "FontWeight", "bold",... "callback" , "perfil()" ,... "BackgroundColor",[0.5 0.7 0.9]); iniperfil=%f; end Aobststr=get(t17,'String'); if Aobststr<>""&aobstcalculada then [Aobst,nerror]=evstr(Aobststr); if nerror<>0 then //no es posible el radioenlace. resp=buttondialog("Qué acción desea realizar ahora?\n- Variar altura de los mástiles.\n- Comenzar y variar todos los parámetros de entrada.\n- Terminar la ejecución del programa.","Mástiles|Comenzar|Terminar","question"); if resp=='1' then //se desea variar las alturas de los mástiles introducidas. close(f2); xdel(); elseif resp=='2' then //se quiere variar los parámetros de entrada. empezar=%t; pantalla2=%f; else //se desea terminar el programa. terminar=%t; pantalla2=%f; end fin=%t; else //es posible el radioenlace. r2 = uicontrol(f2, "Position" , [10 40 180 20],... "Style" , "radiobutton",... "String" , "Variar alturas de los mástiles",... "horizontalalignment","left",... "FontWeight", "bold",... "BackgroundColor",[0.9 0.9 0.9]); r3 = uicontrol(f2, "Position" , [10 10 210 20],... "Style" , "radiobutton",... "String" , "Variar todos los parámetros de entrada",... "horizontalalignment","left",... "FontWeight", "bold",... "BackgroundColor",[0.9 0.9 0.9]); r4 = uicontrol(f2, "Position" , [220 20 80 20],... "Style" , "radiobutton",... "String" , "Continuar",... "horizontalalignment","left",... "FontWeight", "bold",... "BackgroundColor",[0.9 0.9 0.9]); while ~respuesta then //se espera a que el usuario decida si quiere empezar, variar las alturas de los mástiles o continuar. if get(r2,'value')==1&~mastiles then mastiles=%t; respuesta=%t; fin=%t; close(f2); xdel(); else if get(r3,'value')==1&~empezar then empezar=%t; respuesta=%t; fin=%t; pantalla2=%f;

119

APÉNDICE: CÓDIGO FUENTE DE SCILAB

else if get(r4,'value')==1&~continuar then continuar=%t; respuesta=%t; fin=%t; pantalla2=%f; end end end end end aobstcalculada=%f; end end end htstr=string(ht); hrstr=string(hr); Lbf=eval(get(t16,'String')); Lbfstr=string(Lbf); disp('Pérdida básica por propagación (dB):') disp(Lbf) disp('Atenuación en obstáculos (dB):') disp(Aobst) close(f2); xdel(); if empezar then //si se quiere variar los parámetros de entrada. principal(); else if ~terminar then //si se desea continuar con los parámetros actuales. // se crea la pantalla 3. f3 = figure(3,"Position",[50 50 370 650],... "BackgroundColor",[0.9 0.9 0.9],... "Unit", "pixel"); m=uimenu(f3,'label', 'Menú'); m1=uimenu(m,'label', 'Cerrar Figura', 'callback', "fin=%t;"); m2=uimenu(m,'label', 'Cerrar scilab', 'callback', "exit"); fr1= uicontrol(f3, "Position" , [15 480 340 150],... "Style" , "frame",... "BackgroundColor",[0.5 0.3 0.9]); fr2= uicontrol(f3, "Position" , [15 355 340 125],... "Style" , "frame",... "BackgroundColor",[0.5 0.3 0.9]); fr3= uicontrol(f3, "Position" , [15 140 340 215],... "Style" , "frame",... "BackgroundColor",[0.5 0.3 0.9]); fr4= uicontrol(f3, "Position" , [15 80 340 60],... "Style" , "frame",... "BackgroundColor",[0.5 0.3 0.9]); t1 = uicontrol(f3, "Position" , [60 550 160 20],... "Style" , "text",... "String" , "- Polarización:",... "fontsize" , 11,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]);

120

APÉNDICE: CÓDIGO FUENTE DE SCILAB

t2 = uicontrol(f3, "Position" , [60 490 160 20],... "Style" , "text",... "String" , "- Bosque atravesado (m):",... "fontsize" , 11,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t3 = uicontrol(f3, "Position" , [60 400 170 20],... "Style" , "text",... "String" , "- Densidad vapor de agua (g/m3):",... "fontsize" , 11,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t4 = uicontrol(f3, "Position" , [60 275 160 20],... "Style" , "text",... "String" , "- Tiempo p(%):",... "fontsize" , 11,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t5 = uicontrol(f3, "Position" , [60 205 160 20],... "Style" , "text",... "String" , "- Polarización:",... "fontsize" , 11,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t6 = uicontrol(f3, "Position" , [290 595 60 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.5 0.3 0.9]); t7 = uicontrol(f3, "Position" , [290 445 60 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.5 0.3 0.9]); t8 = uicontrol(f3, "Position" , [290 320 60 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.5 0.3 0.9]); l1 = uicontrol(f3, "Position" , [240 515 65 55],... "Style" , "listbox",... "String" , ["H" "V"],... "BackgroundColor",[1 1 1]); l2 = uicontrol(f3, "Position" , [240 365 65 55],... "Style" , "listbox",... "String" , ["7.5" "9" "10"],... "BackgroundColor",[1 1 1]); l3 = uicontrol(f3, "Position" , [240 240 65 55],... "Style" , "listbox",... "String" , ["0.01" "0.05" "0.07"],... "BackgroundColor",[1 1 1]); l4 = uicontrol(f3, "Position" , [240 170 65 55],... "Style" , "listbox",... "String" , ["H" "V"],... "BackgroundColor",[1 1 1]); e1 = uicontrol(f3, "Position" , [240 490 65 20],... "Style" , "edit",... "String" , "",... "horizontalalignment","left",...

121

APÉNDICE: CÓDIGO FUENTE DE SCILAB

"BackgroundColor",[1 1 1]); r1 = uicontrol(f3, "Position" , [20 590 180 30],... "Style" , "radiobutton",... "String" , "Atenuación por vegetación",... "horizontalalignment","left",... "FontWeight", "bold",... "BackgroundColor",[0.5 0.3 0.9]); r2 = uicontrol(f3, "Position" , [20 440 270 30],... "Style" , "radiobutton",... "String" , "Atenuación por gases y vapores atmosféricos",... "horizontalalignment","left",... "FontWeight", "bold",... "BackgroundColor",[0.5 0.3 0.9]); r3 = uicontrol(f3, "Position" , [20 315 180 30],... "Style" , "radiobutton",... "String" , "Atenuación por lluvia",... "horizontalalignment","left",... "FontWeight", "bold",... "BackgroundColor",[0.5 0.3 0.9]); r4 = uicontrol(f3, "Position" , [180 90 90 20],... "Style" , "radiobutton",... "String" , "Hecho",... "horizontalalignment","right",... "FontWeight", "bold",... "BackgroundColor",[0.5 0.3 0.9]); b1 = uicontrol(f3, "Position" , [75 90 100 40],... "Style" , "pushbutton",... "String" , "Capturar datos",... "FontWeight", "bold",... "callback" , "nueva_captura3()" ,... "BackgroundColor",[0.5 0.3 0.9]); buttondialog("Elija de entre los siguientes factores que provocan atenuación en la señal, qué factor o factores quiere que intervengan en el radioenlace.","OK","info"); fin=%f; inicalcular=%t; while ~fin then sleep(1) if get(r4,'value')==1&inicalcular then //los datos capturados son correctos. b2 = uicontrol(f3, "Position" , [30 25 200 40],... "Style" , "pushbutton",... "String" , "CALCULAR",... "FontWeight", "bold",... "callback" , "perdidas2()" ,... "BackgroundColor",[0.5 0.3 0.9]); r5 = uicontrol(f3, "Position" , [230 25 90 20],... "Style" , "radiobutton",... "String" , "Hecho",... "horizontalalignment","right",... "FontWeight", "bold",... "BackgroundColor",[0.9 0.9 0.9]); inicalcular=%f; while get(r5,'value')==0 then //se espera a que haya seleccionado el botón "CALCULAR" y acabe el cálculo de las atenuaciones seleccionadas. end fin=%t; //termina la ejecución de la pantalla 3. end

122

APÉNDICE: CÓDIGO FUENTE DE SCILAB

lab=findobj('label', 'Menú'); if lab==[] then return; end end //se toman los valores de los parámetros necesarios para el cálculo de las atenuaciones seleccionadas. polstr=""; distbosquestr=""; dvastr=""; pstr=""; if get(r1,"value")==1 then if get(l1,"value")==1 then //si el valor introducido por el ususario es polarización horizontal. polstr='H'; else //si el valor introducido por el usuario es polarización vertical. polstr='V'; end distbosquestr=get(e1,"string"); end if get(r2,"value")==1 then select get(l2,"value") //lee el valor de la densidad de vapor de agua introducida por el usuario. case 1 then dvastr='7.5'; case 2 then dvastr='9'; case 3 then dvastr='10'; end end if get(r3,"value")==1 then select get(l3,"value") //lee el valor del tiempo en tanto por ciento de lluvia introducido por el usuario. case 1 then pstr='0.01'; case 2 then pstr='0.05'; case 3 then pstr='0.07'; end if get(l4,"value")==1 then //si el valor introducido por el ususario es de polarización horizontal. polstr='H'; else //si el valor introducido por el usuario es de polarización vertical. polstr='V'; end end Aveg=eval(get(t6,'String')); Agas=eval(get(t7,'String')); Alluv=eval(get(t8,'String')); Lb=Lbf+Aveg+Agas+Alluv+Aobst; potRx=potTx-Lb+Gt+Gr; disp('Potencia recibida (dBW):') disp(potRx) Avegstr=string(Aveg); Agasstr=string(Agas); Alluvstr=string(Alluv); potRxstr=string(potRx);

123

APÉNDICE: CÓDIGO FUENTE DE SCILAB

//se cierra la pantalla 3. close(f3); //se crea la pantalla 4. f4 = figure(4,"Position",[50 50 770 400],... "BackgroundColor",[0.9 0.9 0.9],... "Unit", "pixel"); m=uimenu(f4,'label', 'Menú'); m1=uimenu(m,'label', 'Cerrar Figura', 'callback', "fin=%t;"); m2=uimenu(m,'label', 'Cerrar scilab', 'callback', "exit"); fr1= uicontrol(f4, "Position" , [15 30 340 340],... "Style" , "frame",... "BackgroundColor",[0.5 0.7 0.9]); fr2= uicontrol(f4, "Position" , [400 180 340 190],... "Style" , "frame",... "BackgroundColor",[0.5 0.3 0.9]); t1 = uicontrol(f4, "Position" , [15 375 190 10],... "Style" , "text",... "String" , "PARÁMETROS DE ENTRADA",... "fontsize" , 10,... "horizontalalignment","left",... "BackgroundColor",[0.9 0.9 0.9]); t2 = uicontrol(f4, "Position" , [25 340 230 20],... "Style" , "text",... "String" , "Frecuencia (MHz):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t3 = uicontrol(f4, "Position" , [25 310 230 20],... "Style" , "text",... "String" , "Potencia Tx (dBw):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t4 = uicontrol(f4, "Position" , [25 280 230 20],... "Style" , "text",... "String" , "Ganancia Tx (dB):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t5 = uicontrol(f4, "Position" , [25 250 230 20],... "Style" , "text",... "String" , "Ganancia Rx (dB):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t6 = uicontrol(f4, "Position" , [25 220 230 20],... "Style" , "text",... "String" , "Distancia (Km):",... "fontsize" , 13,... "horizontalalignment", "left",... "BackgroundColor",[0.5 0.7 0.9]); t7 = uicontrol(f4, "Position" , [25 190 230 20],... "Style" , "text",... "String" , "Altura mástil Tx (m):",... "fontsize" , 13,... "horizontalalignment","left",...

124

APÉNDICE: CÓDIGO FUENTE DE SCILAB

"BackgroundColor",[0.5 0.7 0.9]); t8 = uicontrol(f4, "Position" , [25 160 230 20],... "Style" , "text",... "String" , "Altura mástil Rx (m):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t9 = uicontrol(f4, "Position" , [400 375 150 10],... "Style" , "text",... "String" , "BALANCE DE POTENCIAS",... "fontsize" , 10,... "horizontalalignment", "left",... "BackgroundColor",[0.9 0.9 0.9]); t10 = uicontrol(f4, "Position" , [415 340 230 20],... "Style" , "text",... "String" , "Pérdida básica por propagación (dB):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t11 = uicontrol(f4, "Position" , [415 310 230 20],... "Style" , "text",... "String" , "Pérdida en obstáculos (dB):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t12 = uicontrol(f4, "Position" , [415 280 230 20],... "Style" , "text",... "String" , "Atenuación por vegetación (dB):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t13 = uicontrol(f4, "Position" , [415 250 230 20],... "Style" , "text",... "String" , "At. por gases y vap. atmosféricos (dB):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t14 = uicontrol(f4, "Position" , [415 220 230 20],... "Style" , "text",... "String" , "Atenuación por lluvia (dB):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t15 = uicontrol(f4, "Position" , [415 190 230 20],... "Style" , "text",... "String" , "Potencia recibida (dBw):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.3 0.9]); t16 = uicontrol(f4, "Position" , [270 340 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t17 = uicontrol(f4, "Position" , [270 310 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]);

125

APÉNDICE: CÓDIGO FUENTE DE SCILAB

t18 = uicontrol(f4, "Position" , [270 280 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t19 = uicontrol(f4, "Position" , [270 250 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t20 = uicontrol(f4, "Position" , [270 220 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t21 = uicontrol(f4, "Position" , [270 190 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t22 = uicontrol(f4, "Position" , [270 160 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t23 = uicontrol(f4, "Position" , [660 340 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t24 = uicontrol(f4, "Position" , [660 310 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t25 = uicontrol(f4, "Position" , [660 280 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t26 = uicontrol(f4, "Position" , [660 250 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t27 = uicontrol(f4, "Position" , [660 220 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t28 = uicontrol(f4, "Position" , [660 190 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.35 0.95]); t29 = uicontrol(f4, "Position" , [25 130 190 20],... "Style" , "text",... "String" , "Polarización:",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t30 = uicontrol(f4, "Position" , [25 100 190 20],... "Style" , "text",... "String" , "Bosque atravesado (m):",... "fontsize" , 13,...

126

APÉNDICE: CÓDIGO FUENTE DE SCILAB

"horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t31 = uicontrol(f4, "Position" , [25 70 190 20],... "Style" , "text",... "String" , "Densidad vapor agua (g/m3):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t32 = uicontrol(f4, "Position" , [25 40 190 20],... "Style" , "text",... "String" , "Tiempo p (%):",... "fontsize" , 13,... "horizontalalignment","left",... "BackgroundColor",[0.5 0.7 0.9]); t33 = uicontrol(f4, "Position" , [270 130 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t34 = uicontrol(f4, "Position" , [270 100 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t35 = uicontrol(f4, "Position" , [270 70 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); t36 = uicontrol(f4, "Position" , [270 40 70 20],... "Style" , "text",... "String" , "",... "BackgroundColor",[0.55 0.75 0.95]); b1 = uicontrol(f4, "Position" , [510 90 120 40],... "Style" , "pushbutton",... "String" , "TERMINAR",... "FontWeight", "bold",... "callback" , "fin=%t;" ,... "BackgroundColor",[0.5 0.3 0.9]); set(t16,"string",fMHzstr); set(t17,"string",potTxstr); set(t18,"string",Gtstr); set(t19,"string",Grstr); set(t20,"string",dKmstr); set(t21,"string",htstr); set(t22,"string",hrstr); set(t23,"string",Lbfstr); set(t24,"string",Aobststr); set(t25,"string",Avegstr); set(t26,"string",Agasstr); set(t27,"string",Alluvstr); set(t28,"string",potRxstr); set(t33,"string",polstr); set(t34,"string",distbosquestr); set(t35,"string",dvastr); set(t36,"string",pstr); fin=%f; while ~fin then lab=findobj('label', 'Menú'); if lab==[] then return;

127

APÉNDICE: CÓDIGO FUENTE DE SCILAB

end end close(f4); end end return; endfunction function nueva_captura() //captura y almacena variables de entrada introducidas por el usuario. fMHz = ""; potTx = ""; GTx = ""; GRx = ""; nerror=zeros(1,4); set(r1,'value','0'); while fMHz==""|potTx==""|GTx==""|GRx=="" then //se toman datos de la interfaz. fMHz = get(e1,'String') potTx = get(e2,'String') GTx = get(e3,'String') GRx = get(e4,'String') end [fMHz,nerror(1)] = evstr(fMHz); [potTx,nerror(2)] = evstr(potTx); [GTx,nerror(3)] = evstr(GTx); [GRx,nerror(4)] = evstr(GRx); if find(nerror <>0)<>[] then //el tipo de los datos introducidos es incorrecto, se muestra un mensaje por pantalla y se borran los datos de la interfaz. buttondialog("El tipo de datos es incorrecto. Por favor, introduzca de nuevo los parámetros de entrada.","OK","info"); set(e1,'String',"") set(e2,'String',"") set(e3,'String',"") set(e4,'String',"") else //el tipo de los datos es correcto. if fMHz<30|fMHz>30000 then //la frecuencia no está en el rango permitido, se muestra un mensaje por pantalla y se borran los datos de la interfaz. buttondialog("La frecuencia debe estar entre 30MHz y 30GHz para poder considerar PROPAGACIÓN POR ONDA ESPACIAL.", "OK","info"); set(e1,'String',"") set(e2,'String',"") set(e3,'String',"") set(e4,'String',"") else //la frecuencia está en el rango permitido, los datos capturados son correctos. set(r1,'value','1'); end end endfunction function curvas_de_nivel(xUTM,yUTM,cv) //traza curvas de nivel niveles=zeros(1,16); //número de niveles representados en las curvas de nivel. xselect(); set("figure_style","new"); //crea una ventana gráfica. xname("CURVAS DE NIVEL");

128

APÉNDICE: CÓDIGO FUENTE DE SCILAB

//da título a la ventana gráfica. f=gcf(); xset("fpf"," "); //los números de nivel no serán dibujados en las curvas de nivel. xset("colormap",jetcolormap(16)); //establece 16 colores del azul al rojo en el mapa. niveles=round(contour2d(xUTM,yUTM,cv,16,rect=[xUTM(1),yUTM(1),299,yUTM(15)])); //crea las curvas de nivel del terreno. f.figure_size=[730,580]; f.figure_position=[310,50]; a = gca(); xetiqueta=a.x_label; yetiqueta=a.y_label; xetiqueta.text="xUTM"; yetiqueta.text="yUTM"; xetiqueta.foreground=12; xetiqueta.font_size=3; xetiqueta.font_style=8; yetiqueta.foreground=12; yetiqueta.font_size=3; yetiqueta.font_style=8; //establece el formato de las etiquetas de los ejes. t=a.title; t.foreground=12; t.font_size=5; t.font_style=8; t.text="CURVAS DE NIVEL"; //da título al gráfico. //entidades locales y vértices geodésicos. plot2d(276.5,4071.3,style=-9) plot2d(280,4072,style=-9) plot2d(281.5,4062,style=-9) plot2d(283.5,4064.5,style=-9) plot2d(287,4064,style=-9) plot2d(288.5,4071,style=-9) a.children(1).children.mark_background=3; a.children(1).children.mark_foreground=3; a.children(2).children.mark_background=3; a.children(2).children.mark_foreground=3; a.children(3).children.mark_background=3; a.children(3).children.mark_foreground=3; a.children(4).children.mark_background=3; a.children(4).children.mark_foreground=3; a.children(5).children.mark_background=3; a.children(5).children.mark_foreground=3; a.children(6).children.mark_background=3; a.children(6).children.mark_foreground=3; xstring(276.7,4071.1,'El Bosque') xstring(280.2,4071.8,'Benamahoma') xstring(281.7,4061.8,'UBRIQUE') xstring(283.7,4064.5,'Benaocaz') xstring(287.2,4063.6,'Villaluenga Del Rosario') xstring(288.7,4070.8,'GRAZALEMA') a.children(1).font_foreground=3; a.children(2).font_foreground=3; a.children(3).font_foreground=3; a.children(4).font_foreground=3; a.children(5).font_foreground=3; a.children(6).font_foreground=3; plot2d(283.8,4071.8,style=-6) plot2d(287.8,4068.2,style=-6) plot2d(285.7,4064.2,style=-6)

129

APÉNDICE: CÓDIGO FUENTE DE SCILAB

plot2d(288.5,4074.4,style=-6) a.children(1).children.mark_background=16; a.children(1).children.mark_foreground=16; a.children(2).children.mark_background=16; a.children(2).children.mark_foreground=16; a.children(3).children.mark_background=16; a.children(3).children.mark_foreground=16; a.children(4).children.mark_background=16; a.children(4).children.mark_foreground=16; xstring(284,4071.6,'Pinar 1648m') xstring(288,4068,'Reloj 1535m') xstring(285.9,4064.2,'Navazo Alto 1395m') xstring(289,4074.2,'Coros 1328m') a.children(1).font_foreground=16; a.children(2).font_foreground=16; a.children(3).font_foreground=16; a.children(4).font_foreground=16; // crea la leyenda de las curvas de nivel de la ventana gráfica. nivelesimag=niveles; //vector recíproco j=16; for i=1:16 niveles(i)=nivelesimag(j); j=j-1; end legends(string(niveles),1:16,"lr"); legend_axes = f.children(1); for j=2:2:32 legend_axes.children.children(j).thickness = 4; end //pide coordenadas del Tx y Rx buttondialog("Por favor, introduzca puntos dentro de los límites del mapa.","OK","info"); [numbot,xTx,yTx]=xclick(); [numbot,xRx,yRx]=xclick(); while xTx<276|xTx>295|xRx<276|xRx>295|yTx<4061|yTx>4075|yRx<4061|yRx>4075 then buttondialog("Por favor, introduzca puntos dentro de los límites del mapa.","OK","info"); [numbot,xTx,yTx]=xclick(); [numbot,xRx,yRx]=xclick(); end dKm=sqrt((yTx-yRx)^2+(xTx-xRx)^2); plot2d([xTx xRx],[yTx yRx],style=5); xstring(xTx,yTx,"TRANSMISOR"); xstring(xRx,yRx,"RECEPTOR"); a.children(1).font_size=3; a.children(2).font_size=3; a.children(1).font_style=9; a.children(2).font_style=9; a.children(3).children.foreground=-1; a.children(3).children.thickness=2; toolbar(f.figure_id,'off'); dKmstr=string(dKm); xTxstr=string(xTx); yTxstr=string(yTx); xRxstr=string(xRx); yRxstr=string(yRx); set(t12,"string",xTxstr); set(t13,"string",yTxstr); set(t14,"string",xRxstr); set(t15,"string",yRxstr); set(t16,"string",dKmstr); endfunction

130

APÉNDICE: CÓDIGO FUENTE DE SCILAB

function nueva_captura2() //captura las alturas de los mástiles de las antenas introducidas por el usuario. ht=""; hr=""; //variables de entrada introducidas por el usuario. nerror=zeros(1,2); set(r1,'value','0'); if e1<>0 & e2<>0 then while ht==""|hr=="" then ht=get(e1,'String'); hr=get(e2,'String'); end [ht,nerror(1)] = evstr(ht); [hr,nerror(2)] = evstr(hr); if find(nerror <>0)<>[] then //el tipo de los datos introducidos es incorrecto, se muestra un mensaje por pantalla y se borran los datos de la interfaz. buttondialog("El tipo de datos es incorrecto. Por favor, introduzca de nuevo los parámetros de entrada.","OK","info"); set(e1,'String',"") set(e2,'String',"") else //el tipo de los datos es correcto. if ht<altmastilmin|hr<altmastilmin then //las alturas de los mástiles no son las adecuadas, se muestra un mensaje por pantalla y se borran los datos de la interfaz. buttondialog('Según la frecuencia y el perfil seleccionados, la altura mínima del mástil para considerar PROPAGACIÓN POR ONDA ESPACIAL es de '+string(altmastilmin)+' metros.',"OK","info"); set(e1,'String',"") set(e2,'String',"") else //las alturas son válidas, los datos capturados son correctos. set(r1,'value','1'); end end end endfunction function perfil() //traza el perfil del radioenlace y calcula la atenuación producida por los posibles obstáculos. k=4/3; //factor corrección radio terrestre. numinterv=100; //número de intervalos del perfil entre Tx hasta Rx. puntos=numinterv+1; //número de puntos del perfil entre Tx hasta Rx. x=zeros(1,puntos); //abscisas de los puntos del perfil entre Tx y Rx. y=zeros(1,puntos); //ordenadas de los puntos del perfil entre Tx y Rx. RD=zeros(1,puntos); //cotas del rayo directo entre Tx y Rx. R1=zeros(1,puntos); //radio de la primera zona de Fresnel h=zeros(1,puntos); //despejamiento: distancia entre el rayo directo y el obstáculo. hnorm=zeros(1,puntos-2); //despejamiento normalizado: h/R1 d=zeros(5,puntos); //distancias entre cada punto del perfil y los cuatros vértices y el punto notable de la retícula en la que se encuentra.// cpn=[210 625 220 0 0 483 844 1109 1129 1123 919 691 0 1042 1151 1196 1149 0 1329;...

131

APÉNDICE: CÓDIGO FUENTE DE SCILAB

210 669 0 466 479 0 718 1146 1143 1162 1064 848 925 862 945 1262 1295 1231 0;... 0 891 899 779 478 615 684 826 1129 0 1073 1041 994 0 832 972 1139 1298 978;... 306 920 487 458 516 617 749 0 965 1395 1324 1253 1034 0 884 1017 1114 1086 1046;... 0 652 0 0 572 569 892 0 1048 1033 1274 1303 0 0 0 944 1166 1137 1072;... 356 735 0 0 0 468 0 983 1078 1104 1382 1358 1407 0 959 0 1102 959 1159;... 388 426 282 531 518 0 0 985 1295 1201 0 1453 1288 1166 0 975 848 954 0;... 0 0 388 0 507 0 622 886 1197 1305 1492 1569 0 949 845 0 0 1041 0;... 0 0 0 0 812 749 935 0 0 1298 1453 1132 1229 1246 908 0 0 0 875;... 281 0 975 794 841 808 819 0 0 0 1287 1309 1152 0 823 0 964 0 0;... 0 0 0 0 689 0 0 1648 1635 1528 1444 1033 1025 1033 0 0 0 861 0;... 386 0 0 0 0 1197 0 1488 0 0 0 1297 1099 1021 848 0 0 0 0;... 399 496 0 1097 1092 0 1138 1155 0 929 0 1373 965 0 0 702 0 668 0;... 456 489 0 0 965 935 1294 1204 0 1042 0 1349 1328 1068 0 0 583 0 0]; cpn=cpn'; //cotas de los puntos notables del mapa. Si su valor es cero, es que no existe tal punto notable. xpn=[276400 277400 278200 279000 280000 281800 282800 284000 284600 285500 286400 287600 288000 289100 291000 291700 292400 293000 294600;... 276400 277600 278000 279100 280000 281000 283000 284000 284600 285100 286100 287600 288800 289300 290600 291900 292700 293200 294000;... 276000 277900 278200 279200 280900 281600 282900 283500 284300 285000 286700 287400 288600 289000 290400 291800 292800 293500 294800;... 276300 277300 278900 279600 280800 281400 282400 283000 284400 285700 286600 287400 288700 289000 290800 291900 292700 293300 294400;... 276000 277400 278000 279000 280800 281800 282800 283000 284700 285200 286200 287200 288000 289000 290000 292000 292800 293000 294700;... 276300 277200 278000 279000 280000 281600 282000 283800 284300 285600 286800 287700 288300 289000 290300 291000 292500 293500 294400;... 276000 277500 278600 279900 280300 281000 282000 283100 284700 285400 286000 287300 288100 289000 290000 291100 292500 293400 294000;... 276000 277000 278800 279000 280400 281000 282200 283200 284700 285000 286800 287400 288000 289700 290200 291000 292000 293600 294000;... 276000 277000 278000 279000 280500 281200 282500 283000 284000 286000 286800 287700 288700 289100 290400 291000 292000 293000 294600;... 276200 277000 278500 279300 280300 281800 282600 283000 284000 285000 286900 287600 288200 289000 290400 291000 292300 293000 294000;... 276000 277000 278000 279000 280800 281000 282000 283800 284200 285300 286200 287700 288300 289100 290000 291000 292000 293600 294000;... 276300 277000 278000 279000 280000 281900 282000 283100 284000 285000 286000 287500 288000 289200 290200 291000 292000 293000 294000;... 276500 277700 278000 279800 280700 281000 282400 283900 284000 285800 286000 287700 288500 289000 290000 291300 292000 293400 294000;... 276800 277700 278000 279000 280600 281800 282800 283700 284000 285700 286000 287400 288500 289600 290000 291000 292700 293000 294000]; xpn=xpn'; //abscisas de los puntos notables del mapa. ypn=[4061300 4061900 4061100 4061000 4061000 4061700 4061600 4061700 4061500 4061900 4061600 4061500 4061000 4061800 4061100 4061800 4062000 4061000 4061900;... 4062400 4062200 4062000 4062200 4062000 4062000 4062900 4062400 4062600 4062400 4062100 4062500 4062700 4062000 4062200 4062300 4062600 4062800 4062000;... 4063000 4063700 4063200 4063800 4063900 4063800 4063300 4063500 4063600 4063000 4063100 4063200 4063700 4063000 4063700 4063700 4063600 4063400 4063300;... 4064300 4064600 4064800 4064600 4064800 4064500 4064400 4064000 4064200 4064300 4064600 4064700 4064700 4064000 4064900 4064900 4064200 4064200 4064600;... 4065000 4065700 4065000 4065000 4065800 4065400 4065000 4065000 4065800 4065600 4065600 4065100 4065000 4065000 4065000 4065200 4065100 4065800 4065600;... 4066400 4066200 4066000 4066000 4066000 4066400 4066000 4066500 4066700 4066200 4066300 4066600 4066500 4066000 4066400 4066000 4066500 4066200 4066300;... 4067200 4067800 4067100 4067900 4067300 4067000 4067000 4067600 4067800 4067400 4067000 4067100 4067400 4067100 4067000 4067200 4067600 4067600 4067000;... 4068000 4068000 4068700 4068000 4068400 4068000 4068000 4068200 4068300 4068500 4068300 4068300 4068000 4068500 4068500 4068000 4068000 4068300 4068000;... 4069000 4069000 4069000 4069000 4069500 4069100 4069500 4069000 4069000 4069500 4069100 4070000 4069800 4069900 4069200 4069000 4069000 4069000 4069800;... 4070300 4070000 4070700 4070900 4070300 4070400 4070100 4070000 4070000 4070000 4070100 4070600 4070200 4070000 4070300 4070000 4070400 4070000 4070000;... 4071000 4071000 4071000 4071000 4071800 4071000 4071000 4071800 4071600 4071400 4071300 4071600 4071300 4071800 4071000 4071000 4071000 4071400 4071000;...

132

APÉNDICE: CÓDIGO FUENTE DE SCILAB

4072900 4072000 4072000 4072000 4072000 4072000 4072000 4072300 4072000 4072000 4072000 4072600 4072200 4072000 4073000 4072000 4072000 4072000 4072000;... 4073500 4074000 4073000 4073800 4073700 4073000 4073400 4073300 4073000 4073300 4073000 4073800 4073100 4073000 4073000 4073300 4073000 4073000 4073000;... 4074100 4074600 4074000 4074000 4074600 4074500 4074100 4074000 4074000 4074300 4074000 4074000 4074500 4075000 4074000 4074000 4074600 4074000 4074000]; ypn=ypn'; //ordenadas de los puntos notables del mapa. cp=zeros(1,puntos); //cotas de los puntos del perfil entre Tx y Rx. f=zeros(1,puntos); //flecha de los puntos del perfil entre Tx y Rx. cotas=zeros(1,puntos); //cota final de los puntos del perfil entre Tx y Rx, tras considerar la fecha de la Tierra. cotasvano=zeros(1,puntos); //variable auxiliar. numobst=0; comunicacion=%t; xTx=xTx*1000; yTx=yTx*1000; xRx=xRx*1000; yRx=yRx*1000; //conversión a unidades no kilométricas del sistema de medida U.T.M. x(1)=xTx; //abscisa del Tx y(1)=yTx; //ordenada del Tx x(puntos)=xRx; //abscisa del Rx y(puntos)=yRx; //ordenada del Rx teta=atan((y(puntos)-y(1))/(x(puntos)-x(1))); //pendiente sobre plano XY de la línea que une Tx y Rx. if (x(puntos)-x(1))<0 then teta=teta+%pi; end dm=sqrt((yTx-yRx)^2+(xTx-xRx)^2); //distancia entre Tx y Rx en metros. delta=dm/numinterv; //tamaño del intervalo de medición en metros del perfil entre Tx y Rx. nabla=1000; //nabla es el paso de la retícula de datos. for j=1:puntos-1 //cálculo de las coordenadas de los puntos del perfil entre Tx y Rx. x(j+1)=x(j)+delta*cos(teta); y(j+1)=y(j)+delta*sin(teta); end for j=1:puntos //cálculo de las distancias entre cada punto del perfil y los vértices y punto notable de su correspondiente retícula. m=floor(x(j)/nabla); n=floor(y(j)/nabla); mind=m-275; nind=n-4060; d(1,j)=sqrt((x(j)-m*nabla)^2+(y(j)-n*nabla)^2); d(2,j)=sqrt((x(j)-(m+1)*nabla)^2+(y(j)-n*nabla)^2); d(3,j)=sqrt((x(j)-m*nabla)^2+(y(j)-(n+1)*nabla)^2); d(4,j)=sqrt((x(j)-(m+1)*nabla)^2+(y(j)-(n+1)*nabla)^2); d(5,j)=sqrt((x(j)-xpn(mind,nind))^2+(y(j)-ypn(mind,nind))^2); if d(1,j)==0|d(2,j)==0|d(3,j)==0|d(4,j)==0 then

133

APÉNDICE: CÓDIGO FUENTE DE SCILAB

//si la distancia a uno de los vértices es 0, es decir, estamos en uno de ellos auxden=1; if d(1,j)==0 then auxnum=cv(mind,nind); end if d(2,j)==0 then auxnum=cv(mind+1,nind); end if d(3,j)==0 then auxnum=cv(mind,nind+1); end if d(4,j)==0 then auxnum=cv(mind+1,nind+1); end else //si no estamos en ningún vértice auxden=1/(d(1,j)^2)+1/(d(2,j)^2)+1/(d(3,j)^2)+1/(d(4,j)^2); auxnum=cv(mind,nind)/(d(1,j)^2)+cv(mind+1,nind)/(d(2,j)^2)+cv(mind,nind+1)/(d(3,j)^2)+cv(mind+1,nind+1)/(d(4,j)^2); if cpn(mind,nind)<>0&d(5,j)<>0 then //si en esa retícula existe punto notable, se tiene en cuenta. auxden=auxden+1/(d(5,j)^2); auxnum=auxnum+cpn(mind,nind)/(d(5,j)^2); end end cp(j)=auxnum/auxden; f(j)=0.07849/k*sqrt((xTx-x(j))^2+(yTx-y(j))^2)*sqrt((xRx-x(j))^2+(yRx-y(j))^2)/10^6; //cálculo de la flecha en metros. cotas(j)=cp(j)+f(j); //cálculo de las cotas del perfil. end //cotas máximas y mínimas del perfil cotasvano=cotas; cotasvano(1)=[]; cotasvano(puntos-1)=[]; altmax=max(cotasvano); altmin=min(cotasvano); amx=string(altmax); amn=string(altmin); set(t9,"string",amx); set(t10,"string",amn); //dibujo del perfil xselect(); set("figure_style","new"); xname("TRAZAR PERFILES"); f=gcf(); f.figure_size=[730,580]; f.figure_position=[390,50]; axes=gca(); xetiqueta=axes.x_label; yetiqueta=axes.y_label; xetiqueta.text="Longitud del enlace(m)"; xetiqueta.foreground=27; xetiqueta.font_size=3; xetiqueta.font_style=8; yetiqueta.text="Altura (m)"; yetiqueta.foreground=27; yetiqueta.font_size=3; yetiqueta.font_style=8; t=axes.title;

134

APÉNDICE: CÓDIGO FUENTE DE SCILAB

t.foreground=27; t.font_size=5; t.font_style=9; t.text="PERFIL DEL TERRENO"; plot2d([0:delta:dm],cotas,style=27,rect=[1,1,dm,2000]); plot2d3([0:delta:dm],cotas,style=27,rect=[1,1,dm,2000]); plot2d([0 dm],[cotas(1)+ht cotas(puntos)+hr],style=15); //rayo directo en verde axes.children(1).children.thickness=2; //cálculo de posibles obstáculos. [sumAobstred,comunicacion]=calculo_obstaculos(dm,delta,cotas); //pérdida básica por propagación. Lbf=32.45+20*log10(fMHz)+20*log10(dKm); Lbfstr=string(Lbf); set(t16,"string",Lbfstr); if comunicacion==%f then //no es posible el radioenlace. potRx=0; sumAobstredstr="infinita"; else //es posible el radioenlace. potRx=potTx-Lbf-sumAobstred+Gt+Gr; //potencia recibida hasta el momento. sumAobstredstr=string(sumAobstred); end set(t17,"string",sumAobstredstr); potRxstr=string(potRx); set(t18,"string",potRxstr); endfunction function [At,comunicacion]=calculo_obstaculos(dm,delta,cotas) //cálculo de los posibles obstáculos del perfil. puntos=101; At=0; comunicacion=%t; Txprima=zeros(1,15); //altura del transmisor del subvano en estudio. Rxprima=zeros(1,15); //altura del receptor del subvano en estudio. altmax=zeros(1,15); //cota del mayor obstáculo dentro del subvano en estudio. distmax=zeros(1,15); //distancia del mayor obstáculo al Tx correspondiente al subvano en estudio. distvanom=zeros(1,15); //longitud del subvano en estudio. distabs=zeros(1,15); //distancia de los obstáculos al Tx original del perfil. hn=zeros(1,15); //máximo despejamiento normalizado del vano en estudio. indmax=zeros(1,15); //índice relativo del máximo despejamiento normalizado del vano en estudio. distorden=zeros(1,15); //distancia de los obstáculos al Tx original ordenados por su proximidad al mismo. altorden=zeros(1,15); //cota de los obstáculos ordenados por su proximidad al Tx original. hnorm=zeros(1,puntos-2); //despejamiento normalizado en el vano original. hnormsub1=zeros(1,puntos-2); hnormsub2=zeros(1,puntos-2);

135

APÉNDICE: CÓDIGO FUENTE DE SCILAB

hnormsub11=zeros(1,puntos-2); hnormsub12=zeros(1,puntos-2); hnormsub21=zeros(1,puntos-2); hnormsub22=zeros(1,puntos-2); hnormsub111=zeros(1,puntos-2); hnormsub112=zeros(1,puntos-2); hnormsub121=zeros(1,puntos-2); hnormsub122=zeros(1,puntos-2); hnormsub211=zeros(1,puntos-2); hnormsub212=zeros(1,puntos-2); hnormsub221=zeros(1,puntos-2); hnormsub222=zeros(1,puntos-2); //hnorm de los 15 subvanos de estudio en los que se dividirá el perfil. distanciam=zeros(1,puntos-2); //distancia de las muestras al Tx en metros del vano original. distanciamsub1=zeros(1,puntos-2); distanciamsub2=zeros(1,puntos-2); distanciamsub11=zeros(1,puntos-2); distanciamsub12=zeros(1,puntos-2); distanciamsub21=zeros(1,puntos-2); distanciamsub22=zeros(1,puntos-2); distanciamsub111=zeros(1,puntos-2); distanciamsub112=zeros(1,puntos-2); distanciamsub121=zeros(1,puntos-2); distanciamsub122=zeros(1,puntos-2); distanciamsub211=zeros(1,puntos-2); distanciamsub212=zeros(1,puntos-2); distanciamsub221=zeros(1,puntos-2); distanciamsub222=zeros(1,puntos-2); //distancias al Tx de los elementos de los 15 subvanos de estudio en los que se dividirá el perfil. obstaculoreal=[%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f ]; //indica si realmente supone o no un obstáculo en la comunicación. distanciam=(1:puntos-2)*delta; //distancia hasta su Txprima correspondiente. nrd=1; Txprima(nrd)=cotas(1)+ht; Rxprima(nrd)=cotas(puntos)+hr; distvanom(nrd)=dm; indinicotas=2; hnorm=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciam); if find(hnorm>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnorm<-0.6); if length(w)==length(hnorm) then buttondialog('NO HAY DIFRACCIÓN EN EL VANO ORIGINAL',"OK","info"); return; else buttondialog('HAY DIFRACCIÓN EN EL VANO ORIGINAL',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnorm); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([0 distabs(nrd) dm],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. //SUBVANO 1 distanciamsub1=distanciam;

136

APÉNDICE: CÓDIGO FUENTE DE SCILAB

for i=indmax(nrd):length(distanciam) distanciamsub1(indmax(nrd))=[]; end if distanciamsub1<>[] then nrd=2; Txprima(nrd)=Txprima(1); Rxprima(nrd)=altmax(1); distvanom(nrd)=(length(distanciamsub1)+1)*delta; indinicotas=2; hnormsub1=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub1); if find(hnormsub1>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub1<-0.6); if length(w)==length(hnormsub1) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 1',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 1',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub1); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([0 distabs(nrd) distabs(1)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. //SUBVANO 11 distanciamsub11=distanciamsub1; for i=indmax(nrd):length(distanciamsub1) distanciamsub11(indmax(nrd))=[]; end if distanciamsub11<>[] then nrd=4; Txprima(nrd)=Txprima(1); Rxprima(nrd)=altmax(2); distvanom(nrd)=(length(distanciamsub11)+1)*delta; indinicotas=2; hnormsub11=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub11); if find(hnormsub11>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub11<-0.6); if length(w)==length(hnormsub11) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 11',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 11',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub11); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1);

137

APÉNDICE: CÓDIGO FUENTE DE SCILAB

altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([0 distabs(nrd) distabs(2)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. //SUBVANO 111 distanciamsub111=distanciamsub11; for i=indmax(nrd):length(distanciamsub11) distanciamsub111(indmax(nrd))=[]; end if distanciamsub111<>[] then nrd=8; Txprima(nrd)=Txprima(1); Rxprima(nrd)=altmax(4); distvanom(nrd)=(length(distanciamsub111)+1)*delta; indinicotas=2; hnormsub111=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub111); if find(hnormsub111>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub111<-0.6); if length(w)==length(hnormsub111) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 111',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 111',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub111); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([0 distabs(nrd) distabs(4)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. end else buttondialog('EL SUBVANO 111 NO POSEE MUESTRAS.',"OK","info"); end //SUBVANO 112 distanciamsub112=distanciamsub11; for i=1:indmax(4) distanciamsub112(1)=[]; end if distanciamsub112<>[] then distanciamsub112=distanciamsub112-distabs(4); nrd=9; Txprima(nrd)=altmax(4); Rxprima(nrd)=altmax(2); distvanom(nrd)=(length(distanciamsub112)+1)*delta; indinicotas=indiceabs(4)+1; hnormsub112=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub112); if find(hnormsub112>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f;

138

APÉNDICE: CÓDIGO FUENTE DE SCILAB

return; end w=find(hnomsub112<-0.6); if length(w)==length(hnormsub112) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 112',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 112',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub112); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distmax(4)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(4) distabs(nrd) distabs(2)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. end else buttondialog('EL SUBVANO 112 NO POSEE MUESTRAS.',"OK","info"); end end else buttondialog('EL SUBVANO 11 NO POSEE MUESTRAS.',"OK","info"); end //SUBVANO 12 distanciamsub12=distanciamsub1; for i=1:indmax(2) distanciamsub12(1)=[]; end if distanciamsub12<>[] then distanciamsub12=distanciamsub12-distabs(2); nrd=5; Txprima(nrd)=altmax(2); Rxprima(nrd)=altmax(1); distvanom(nrd)=(length(distanciamsub12)+1)*delta; indinicotas=indiceabs(2)+1; hnormsub12=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub12); if find(hnormsub12>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnomsub12<-0.6); if length(w)==length(hnormsub12) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 12',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 12',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub12); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(2)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(2) distabs(nrd) distabs(1)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. //SUBVANO 121 distanciamsub121=distanciamsub12; for i=indmax(nrd):length(distanciamsub12)

139

APÉNDICE: CÓDIGO FUENTE DE SCILAB

distanciamsub121(indmax(nrd))=[]; end if distanciamsub121<>[] then nrd=10; Txprima(nrd)=altmax(2); Rxprima(nrd)=altmax(5); distvanom(nrd)=(length(distanciamsub121)+1)*delta; indinicotas=indiceabs(2)+1; hnormsub121=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub121); if find(hnormsub121>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnomsub121<-0.6); if length(w)==length(hnormsub121) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 121',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 121',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub121); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(2)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(2) distabs(nrd) distabs(5)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. end else buttondialog('EL SUBVANO 121 NO POSEE MUESTRAS.',"OK","info"); end //SUBVANO 122 distanciamsub122=distanciamsub12; for i=1:indmax(5) distanciamsub122(1)=[]; end if distanciamsub122<>[] then distanciamsub122=distanciamsub122-(distabs(5)-distabs(2)); nrd=11; Txprima(nrd)=altmax(5); Rxprima(nrd)=altmax(1); distvanom(nrd)=(length(distanciamsub122)+1)*delta; indinicotas=indiceabs(5)+1; hnormsub122=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub122); if find(hnormsub122>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnomsub122<-0.6); if length(w)==length(hnormsub122) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 122',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 122',"OK","info"); obstaculoreal(nrd)=%t;

140

APÉNDICE: CÓDIGO FUENTE DE SCILAB

[hn(nrd),indmax(nrd)]=max(hnormsub122); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(5)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(5) distabs(nrd) distabs(1)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. end else buttondialog('EL SUBVANO 122 NO POSEE MUESTRAS.',"OK","info"); end end else buttondialog('EL SUBVANO 12 NO POSEE MUESTRAS.',"OK","info"); end end else buttondialog('EL SUBVANO 1 NO POSEE MUESTRAS.',"OK","info"); end //SUBVANO 2 distanciamsub2=distanciam; for i=1:indmax(1) distanciamsub2(1)=[]; end if distanciamsub2<>[] then distanciamsub2=distanciamsub2-distabs(1); nrd=3; Txprima(nrd)=altmax(1); Rxprima(nrd)=Rxprima(1); distvanom(nrd)=(length(distanciamsub2)+1)*delta; indinicotas=indiceabs(1)+1; hnormsub2=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub2); if find(hnormsub2>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub2<-0.6); if length(w)==length(hnormsub2) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 2',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 2',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub2); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(1)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(1) distabs(nrd) dm],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. //SUBVANO 21 distanciamsub21=distanciamsub2; for i=indmax(nrd):length(distanciamsub2) distanciamsub21(indmax(nrd))=[]; end if distanciamsub21<>[] then

141

APÉNDICE: CÓDIGO FUENTE DE SCILAB

nrd=6; Txprima(nrd)=altmax(1); Rxprima(nrd)=altmax(3); distvanom(nrd)=(length(distanciamsub21)+1)*delta; indinicotas=indiceabs(1)+1; hnormsub21=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub21); if find(hnormsub21>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub21<-0.6); if length(w)==length(hnormsub21) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 21',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 21',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub21); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(1)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(1) distabs(nrd) distabs(3)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. //SUBVANO 211 distanciamsub211=distanciamsub21; for i=indmax(nrd):length(distanciamsub21) distanciamsub211(indmax(nrd))=[]; end if distanciamsub211<>[] then nrd=12; Txprima(nrd)=altmax(1); Rxprima(nrd)=altmax(6); distvanom(nrd)=(length(distanciamsub211)+1)*delta; indinicotas=indiceabs(1)+1; hnormsub211=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub211); if find(hnormsub211>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub211<-0.6); if length(w)==length(hnormsub211) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 211',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 211',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub211); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(1)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(1) distabs(nrd) distabs(6)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa.

142

APÉNDICE: CÓDIGO FUENTE DE SCILAB

end else buttondialog('EL SUBVANO 211 NO POSEE MUESTRAS.',"OK","info"); end //SUBVANO 212 distanciamsub212=distanciamsub21; for i=1:indmax(6) distanciamsub212(1)=[]; end if distanciamsub212<>[] then distanciamsub212=distanciamsub212-(distabs(6)-distabs(1)); nrd=13; Txprima(nrd)=altmax(6); Rxprima(nrd)=altmax(3); distvanom(nrd)=(length(distanciamsub212)+1)*delta; indinicotas=indiceabs(6)+1; hnormsub212=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub212); if find(hnormsub212>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub212<-0.6); if length(w)==length(hnormsub212) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 212',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 212',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub212); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(6)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(6) distabs(nrd) distabs(3)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. end else buttondialog('EL SUBVANO 212 NO POSEE MUESTRAS.',"OK","info"); end end else buttondialog('EL SUBVANO 21 NO POSEE MUESTRAS.',"OK","info"); end //SUBVANO 22 distanciamsub22=distanciamsub2; for i=1:indmax(3) distanciamsub22(1)=[]; end if distanciamsub22<>[] then distanciamsub22=distanciamsub22-(distabs(3)-distabs(1)); nrd=7; Txprima(nrd)=altmax(3); Rxprima(nrd)=Rxprima(1); distvanom(nrd)=(length(distanciamsub22)+1)*delta; indinicotas=indiceabs(3)+1;

143

APÉNDICE: CÓDIGO FUENTE DE SCILAB

hnormsub22=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub22); if find(hnormsub22>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub22<-0.6); if length(w)==length(hnormsub22) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 22',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 22',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub22); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(3)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(3) distabs(nrd) dm],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. //SUBVANO 221 distanciamsub221=distanciamsub22; for i=indmax(nrd):length(distanciamsub22) distanciamsub221(indmax(nrd))=[]; end if distanciamsub221<>[] then nrd=14; Txprima(nrd)=altmax(3); Rxprima(nrd)=altmax(7); distvanom(nrd)=(length(distanciamsub221)+1)*delta; indinicotas=indiceabs(3)+1; hnormsub221=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub221); if find(hnormsub221>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnomsub221<-0.6); if length(w)==length(hnormsub221) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 221',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 221',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub221); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(3)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(3) distabs(nrd) distabs(7)],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. end else buttondialog('EL SUBVANO 221 NO POSEE MUESTRAS.',"OK","info"); end

144

APÉNDICE: CÓDIGO FUENTE DE SCILAB

//SUBVANO 222 distanciamsub222=distanciamsub22; for i=1:indmax(7) distanciamsub222(1)=[]; end if distanciamsub222<>[] then distanciamsub222=distanciamsub222-(distabs(7)-distabs(3)); nrd=15; Txprima(nrd)=altmax(7); Rxprima(nrd)=Rxprima(1); distvanom(nrd)=(length(distanciamsub222)+1)*delta; indinicotas=indiceabs(7)+1; hnormsub222=despejamiento_norm(Txprima(nrd),Rxprima(nrd),distvanom(nrd),cotas,indinicotas,distanciamsub222); if find(hnormsub222>0.5)<>[] then buttondialog('NO ES POSIBLE EL RADIOENLACE',"OK","info"); comunicacion=%f; return; end w=find(hnormsub222<-0.6); if length(w)==length(hnormsub222) then buttondialog('NO HAY DIFRACCIÓN EN EL SUBVANO 222',"OK","info"); else buttondialog('HAY DIFRACCIÓN EN EL SUBVANO 222',"OK","info"); obstaculoreal(nrd)=%t; [hn(nrd),indmax(nrd)]=max(hnormsub222); distmax(nrd)=indmax(nrd)*delta; distabs(nrd)=distabs(7)+distmax(nrd); indiceabs(nrd)=ceil(distabs(nrd)/delta+1); altmax(nrd)=cotas(indiceabs(nrd)); plot2d3(distabs(nrd),altmax(nrd)) plot2d([distabs(7) distabs(nrd) dm],[Txprima(nrd) altmax(nrd) Rxprima(nrd)],style=6); //polígono auxiliar en rosa. end else buttondialog('EL SUBVANO 222 NO POSEE MUESTRAS.',"OK","info"); end end else buttondialog('EL SUBVANO 22 NO POSEE MUESTRAS.',"OK","info"); end end else buttondialog('EL SUBVANO 2 NO POSEE MUESTRAS.',"OK","info"); end end hn=solo_reales(hn,obstaculoreal); distabs=solo_reales(distabs,obstaculoreal); distmax=solo_reales(distmax,obstaculoreal); altmax=solo_reales(altmax,obstaculoreal); Txprima=solo_reales(Txprima,obstaculoreal); Rxprima=solo_reales(Rxprima,obstaculoreal); //elimina, si se da el caso, los obstáculos que estaban en estudio y que realmente no son obstáculos. hn=elimina_ceros(hn); distabs=elimina_ceros(distabs); distmax=elimina_ceros(distmax); altmax=elimina_ceros(altmax); Txprima=elimina_ceros(Txprima); Rxprima=elimina_ceros(Rxprima); //elimina subvanos en los que no se ha encontrado obstáculo real.

145

APÉNDICE: CÓDIGO FUENTE DE SCILAB

At=perdidas(cotas,distabs,distmax,altmax,delta,hn,Txprima,Rxprima); //calcula pérdidas en obstáculos. [distorden,altorden]=ordena(distabs,altmax); //ordena los obstáculos según su proximidad al Tx original para su posterior representación. xfunic=[0 distorden dm]; yfunic=[Txprima(1) altorden Rxprima(1)]; plot2d(xfunic,yfunic,style=11); //traza la línea funicular. toolbar(f.figure_id,'off'); endfunction function hnorm=despejamiento_norm(Txprima,Rxprima,dvanom,cotas,indinicotas,distanciam) //calcula el despejamiento normalizado de todas las muestra del subvano en estudio. npuntos=length(distanciam); RD=zeros(1,npuntos); R1=zeros(1,npuntos); h=zeros(1,npuntos); hnorm=zeros(1,npuntos); dvanoKm=dvanom/1000; pendRD=(Rxprima-Txprima)/dvanoKm; RD=Txprima+pendRD*distanciam/1000; //cotas del rayo directo del vano en estudio. for i=1:npuntos //despejamiento en metros del vano en estudio. R1(i)=550*sqrt((distanciam(i)/1000)*(dvanoKm-distanciam(i)/1000)/fMHz/dvanoKm); //radio de la primera zona de Fresnel del vano en estudio. h(i)=cotas(indinicotas)-RD(i); hnorm(i)=h(i)/R1(i); indinicotas=indinicotas+1; end endfunction function [cad]=solo_reales(cadena,obstreal) //elimina obstáculos en estudio que finalmente no se pueden considerar obstáculos. long=length(cadena); cad=zeros(1,long); cad=cadena; for i=1:long if obstreal(i)<>%t then cad(i)=0; end end endfunction function cad=elimina_ceros(cadena) //copia de la cadena que se le pasa como parámetro y la devuelve sin los elementos nulos. cad=zeros(1,15); //distancia de los obstáculos al Tx del vano en estudio. cad=cadena; i=1; long=length(cad); while i<=long then if cad(i)==0 then cad(i)=[]; long=length(cad); i=i-1; end i=i+1; end endfunction

146

APÉNDICE: CÓDIGO FUENTE DE SCILAB

function at=perdidas(cotas,dist,distmax,alt,delta,hn,Txprima,Rxprima) //cálculo de pérdidas por difracción en obstáculos. z0=cotas(1)+ht; zd=cotas(101)+hr; redondeado=%f; sumAobstagu=0; sumcorreccionT=0; numobst=length(dist); sumAobstagu=atenuacion_agudos(hn); //calcula la atenuación en los obstáculos agudos. for i=1:numobst redondeado=es_redondeado(cotas,dist(i),delta); if redondeado==%f then //obstáculo agudo. T=0; else //obstáculo redondeado. [dht,dhr,zht,zhr]=calculo_tangente(cotas,Txprima(i),Rxprima(i),delta,alt(i),distmax(i)) T=atenuacion_redondeados(dht,dhr,zht,zhr,z0,zd); //calcula la atenuación en los obstáculos redondeados. end sumcorreccionT=sumcorreccionT+T; end at=sumAobstagu+sumcorreccionT; if numobst==2 then //hay dos obstáculos en el perfil. if hn(1)>1.5*hn(2)then //el obstáculo 1 es el predominante. else if hn(2)>1.5*hn(1) then //el obstáculo 2 es el predominante. else //los obstáculos producen pérdidas similares; no existe ninguno dominante. Lc=10*log10(); at=at+ end end else if numobst<>1 then //hay múltiples obstáculos en el perfil. end end endfunction function sumAobstagu=atenuacion_agudos(hn) //calcula la atenuación creada por obstáculos agudos. numobst=length(hn); nu=zeros(1,numobst); //parámetro adimensional. Aobstagu=zeros(1,numobst); //atenuación en los obstáculos agudos. for i=1:numobst nu(i)=sqrt(2)*hn(i); if nu(i)>-0.78 then //critero para que la atenuación no sea nula. Se expecifica para hacer énfasis en que se debe cumplir esta condición, //aunque esta función sólo trabaja con aquellas muestras que fueron consideradas obstáculos por cumplir -0,6<=h/R1<=0.5, //que equivale a -0.4243<=nu<=0.3536. Aobstagu(i)=6.9+20*log10(sqrt((nu(i)-0.1)^2+1)+nu(i)-0.1); else

147

APÉNDICE: CÓDIGO FUENTE DE SCILAB

Aobstagu(i)=0; end end sumAobstagu=sum(Aobstagu); endfunction function redondo=es_redondeado(cotas,distTxm,delta) //comprueba si la pendiente del obstáculo es pronunciada o no. redondo=%t; indice=distTxm/delta+1; select indice case 2 then nmuestras=4; dcotas=zeros(1,nmuestras); //diferencia de cotas del obstáculo con puntos de su entorno. dcotas=[cotas(indice)-cotas(indice-1) cotas(indice+1)-cotas(indice) cotas(indice+2)-cotas(indice+1) cotas(indice+3)-cotas(indice+2)]; case 3 then nmuestras=5; dcotas=zeros(1,nmuestras); dcotas=[cotas(indice-1)-cotas(indice-2) cotas(indice)-cotas(indice-1) cotas(indice+1)-cotas(indice) cotas(indice+2)-cotas(indice+1)... cotas(indice+3)-cotas(indice+2)]; case 99 then nmuestras=5; dcotas=zeros(1,nmuestras); dcotas=[cotas(indice-2)-cotas(indice-3) cotas(indice-1)-cotas(indice-2) cotas(indice)-cotas(indice-1) cotas(indice+1)-cotas(indice)... cotas(indice+2)-cotas(indice+1)]; case 100 then nmuestras=4; dcotas=zeros(1,nmuestras); dcotas=[cotas(indice-2)-cotas(indice-3) cotas(indice-1)-cotas(indice-2) cotas(indice)-cotas(indice-1) cotas(indice+1)-cotas(indice)]; else nmuestras=6; dcotas=zeros(1,nmuestras); dcotas=[cotas(indice-2)-cotas(indice-3) cotas(indice-1)-cotas(indice-2) cotas(indice)-cotas(indice-1) cotas(indice+1)-cotas(indice)... cotas(indice+2)-cotas(indice+1) cotas(indice+3)-cotas(indice+2)]; end if find(dcotas)>100<>[] then //si hay ninguna diferencia de alturas mayor que 100 es que el obtáculo es agudo. redondo=%f; end endfunction function [dht,dhr,zht,zhr]=calculo_tangente(cotas,Txprima,Rxprima,delta,altmax,distmax) // poner que Txprima, Rxprima sea como máximo 2000 para que se pueda representar en el gráfico. dht=-1; dhr=-1; zht=-1; zhr=-1; //cálculo de los posibles obstáculos del perfil. dm=dKm*1000; //f=gcf(); //puede que no haga falta. indmax=distmax/delta+1; //como representante del obstáculo redondeado se toma la muestra en la que está el obstáculo, 3 puntos anteriores y 3 posteriores en cotasvano. //en caso de que no se puedan tomar 3 muestras anteriores o posteriores, por estar el obstáculo muy cerca del Tx o del Rx, //se toman las muestras que sea posible.

148

APÉNDICE: CÓDIGO FUENTE DE SCILAB

select indmax case 2 np=5; indinf=1; indsup=5; case 3 np=6; indinf=1; indsup=6; case 99 np=6; indinf=96; indsup=101; case 100 np=5; indinf=97; indsup=101; else np=7; indinf=indmax-(np-1)/2; indsup=indmax+(np-1)/2; end xpuntosalr=zeros(1,np); //xpuntosalr en m xpuntosalr=delta*[(indinf-1):(indsup-1)]; ypuntosalr=zeros(1,np); ypuntosalr=cotas(indinf:indsup); //6 segmentos de la forma f(x)=a+bx, que conforman el perfil del obstáculo redondeado. a=zeros(1,np-1); b=zeros(1,np-1); cotafinal=zeros(1,np-1); for i=1:6 a(i)=ypuntosalr(i); b(i)=(ypuntosalr(i+1)-ypuntosalr(i))/(xpuntosalr(i+1)-xpuntosalr(i)); cotafinal(i)=a(i)+b(i)*(xpuntosalr(i+1)-xpuntosalr(i)); end //se toman dos rectas auxliares de la forma f(x)=a+bx, que en principio coinciden con el rayo directo, y cuyas pendientes se irán modificando //hasta que sean tangentes al obstáculo. Una de esta rectas siempre pasará por el Tx y la otra, por el Rx. //recta tangente que siempre parte del Tx. Se irá modificando su pendiente, bTx. aTx=Txprima; bTx=(Rxprima-Txprima)/dm; limsupbTx=2000/delta; liminfbTx=-2000/delta; fin=%f; while fin==%f then //primero recta tangente desde el Tx. ncortes=0; xTxcorte=zeros(1,np-1); //el punto de tangencia se busca hallando la intersección de la recta auxiliar con los distintos segmentos del perfil. //cuando sólo haya un punto de corte con el perfil, entonces, se habrá encontrado el punto de tangencia. for i=1:np-1 xTxcorte(i)=(aTx+b(i)*xpuntosalr(i)-a(i))/(b(i)-bTx); if xpuntosalr(i)<=xTxcorte(i)&xTxcorte(i)<=xpuntosalr(i+1) then //corta al segmento i. ncortes=ncortes+1; else //no corta con el segmento i. xTxcorte(i)=-1; end

149

APÉNDICE: CÓDIGO FUENTE DE SCILAB

end select ncortes, case 2 then //se está seccionando el obstáculo, hay que aumentar la pendiente. liminfbTx=bTx; bTx=(limsupbTx+liminfbTx)/2; case 0 then //no secciona el obstáculo. altrectaTx=aTx+bTx*distmax; if altmax>altrectaTx then //la recta secciona a la vertical del obstáculo por debajo de éste; hay que aumentar la pendiente. liminfbTx=bTx; else //la recta secciona a la vertical del obstáculo por encima de éste; hay que disminuir la pendiente. limsupbTx=bTx; end bTx=(limsupbTx+liminfbTx)/2; case 1 then //hay un único punto de intersección. segmento=find(xTxcorte<>-1); xht=xTxcorte(segmento); extremo=find(xpuntosalr=xht); if extremo==[] then //el punto de corte no coincide con ninguno de los extremos de los segmentos del perfil del obstáculo. //dado que intersecciona con el perfil, hay que aumentar la pendiente. liminfbTx=bTx; bTx=(limsupbTx+liminfbTx)/2; else //el punto de corte es uno de los extremos de los segmentos del perfil del obstáculo. altrectaTx=aTx+bTx*distmax; if altmax>altrectaTx then //no es punto tangente real (queda "debajo" del perfil"); hay que aumentar la pendiente. liminfbTx=bTx; bTx=(limsupbTx+liminfbTx)/2; else //se ha encontrado el punto tangente,ya se puede conocer la altura zht. zht=ypuntosalr(segmento); plot2d([0 dm],[aTx aTx+bTx*dm],style=7); plot2d([xht xht],[0 zht],style=15); fin=%t; end end else //ncortes negativo. break; end end //dibuja obstáculo imagen xpuntosimagen=zeros(1,np); ypuntosimagen=zeros(1,np); indinv=dm/delta-indmax+2; select indinv case 2 indinf=1; indsup=5; case 3 indinf=1; indsup=6; case 99 indinf=96; indsup=101; case 100 indinf=97; indsup=101; else

150

APÉNDICE: CÓDIGO FUENTE DE SCILAB

indinf=indinv-(np-1)/2; indsup=indinv+(np-1)/2; end xpuntosimagen=delta*[(indinf-1):(indsup-1)]; for i=1:np ypuntosimagen(i)=ypuntosalr(np+1-i); end for i=1:np-1 a(i)=ypuntosimagen(i); b(i)=(ypuntosimagen(i+1)-ypuntosimagen(i))/(xpuntosimagen(i+1)-xpuntosimagen(i)); cotafinal(i)=a(i)+b(i)*(xpuntosimagen(i+1)-xpuntosimagen(i)); end //recta tangente que siempre parte del Rx. Se irá modificando la pendiente bRx y el punto inicial aRx. aRx=Rxprima; bRx=-(Rxprima-Txprima)/dm; limsupbRx=2000/delta; liminfbRx=-2000/delta; fin=%f; while fin==%f then //primero recta tangente desde el Rx. ncortes=0; xRxcorte=zeros(1,np-1); //el punto de tangencia se busca hallando la intersección de la recta auxiliar con los distintos segmentos del perfil. //cuando sólo haya un punto de corte con el perfil, entonces, se habrá encontrado el punto de tangencia. for i=1:np-1 xRxcorte(i)=(aRx+b(i)*xpuntosimagen(i)-a(i))/(b(i)-bRx); if xpuntosimagen(i)<=xRxcorte(i)&xRxcorte(i)<=xpuntosimagen(i+1) then //corta al segmento i. ncortes=ncortes+1; else //no corta con el segmento i. xRxcorte(i)=-1; end end select ncortes, case 2 then //se está seccionando el obstáculo, hay que aumentar la pendiente. liminfbRx=bRx; bRx=(limsupbRx+liminfbRx)/2; case 0 then //no secciona el obstáculo. altrectaRx=aRx+bRx*(dm-distmax); if altmax>altrectaRx then //la recta secciona a la vertical del obstáculo por debajo de éste; hay que aumentar la pendiente. liminfbRx=bRx; else //la recta secciona a la vertical del obstáculo por encima de éste; hay que disminuir la pendiente. limsupbRx=bRx; end bRx=(limsupbRx+liminfbRx)/2; case 1 then //hay un único punto de intersección. segmentoimagen=find(xRxcorte<>-1); xhrimagen=xRxcorte(segmentoimagen); extremoimagen=find(xpuntosimagen=xhrimagen); if extremoimagen==[] then //el punto de corte no coincide con ninguno de los extremos de los segmentos del perfil del obstáculo. //dado que intersecciona con el perfil, hay que aumentar la pendiente. liminfbRx=bRx; bRx=(limsupbRx+liminfbRx)/2; else //el punto de corte es uno de los extremos de los segmentos del perfil del obstáculo.

151

APÉNDICE: CÓDIGO FUENTE DE SCILAB

altrectaRx=aRx+bRx*(dm-distmax); if altmax>altrectaRx then //no es punto tangente real (queda "debajo" del perfil"); hay que aumentar la pendiente. liminfbRx=bRx; bRx=(limsupbRx+liminfbRx)/2; else //se ha encontrado el punto tangente,ya se puede conocer la altura zht. segmento=7-segmentoimagen; zhr=ypuntosimagen(segmento); plot2d([0 dm],[aRx+bRx*dm aRx],style=7); plot2d([xhrimagen xhrimagen],[0 zhr],style=15); fin=%t; end end else //ncortes negativo. break; end end xhr=dm-xhrimagen; //distancia real de intersección con el obstáculo real (y no el imagen). if xht==xhr then //coinciden ambos puntos de tangencia. xcorte=xht; hpi=zht; //altura en metros del punto de intersección de las dos rectas tangentes. dht=sqrt(xht^2+(Txprima-hpi)^2); dhr=sqrt((dm-xht)^2+(Rxprima-hpi)^2); else //no coinciden los puntos de tangencia; hay que hallar la intersección de las rectas tangentes, que nos dará la altura //de dicho punto y las distancias a Txprima y Rxprima, a partir de la igualdad: f1(x)=a1+b1x=f2(x)=a2-b2(x-dm) xcorte=(aRx+bRx*dm-aTx)/(bTx+bRx); hpi=aTx+bTx*xcorte; dht=sqrt(xcorte^2+(Txprima-hpi)^2); dhr=sqrt((dm-xcorte)^2+(Rxprima-hpi)^2); end endfunction function T=atenuacion_redondeados(dht,dhr,zht,zhr,z0,zd) //calculos de la corrección en la atenuación por obstáculo redondeado. R0=6370; //radio terrestre. tetam=(zht-z0)/dht+(zhr-zd)/dhr+dKm/(2*R0); //ángulo de difracción. betam=(zd-z0)/dKm+(zd-zhr)/dhr; xp=dKm*betam/tetam; //abscisa del punto de intersección de las visuales trazadas desde el transmisor y el receptor a sus respectivos horizontes. r=(dKm-dht-dhr)*1000/tetam; //radio de curvatura del obstáculo. h=xp*((zht-z0)/dht-(zd-z0)/dKm); //altura del punto de intersección de las visuales trazadas desde el transmisor y el receptor a sus respectivos horizontes. m=0.45708*dKm/(xp*(dKm-xp))*r^(2/3)*fMHz^(-1/3); n=4.787*10^(-3)*h*fMHz^(2/3)*r^(-1/3); //parámetros radioeléctricos para el cálculo de la difracción. if m*n<= 4 then T=7.2*m^(1/2)-(2-12.5*n)*m+3.6*m^(3/2)-0.8*m^2; else T=-6-20*log10(m*n)+7.2*m^(1/2)-(2-17*n)*m+36*m^(3/2)-0.8*m^2; end endfunction function [distord,altord]=ordena(d,alt)

152

APÉNDICE: CÓDIGO FUENTE DE SCILAB

//ordena los obstáculos hallados según su proximidad al Tx original, por el método de inserción. distord=zeros(1,15); //distancia de los obstáculos al Tx original ordenados por su proximidad al mismo. altord=zeros(1,15); //cota de los obstáculos ordenados por su proximidad al Tx original. distord=d; altord=alt; i=1; while i<length(distord) then i=i+1; elemdist=distord(i); elemalt=altord(i); j=i-1; while j>=1&elemdist<distord(j) then distord(j+1)=distord(j); altord(j+1)=altord(j); j=j-1; end distord(j+1)=elemdist; altord(j+1)=elemalt; end endfunction function nueva_captura3() //captura los factores que el usuario quiere que se tengan en cuenta en el cálculo de la atenuación que sufre la señal. set(r4,'value','0'); veg=%f; gas=%f; lluv=%f; bosque=""; if get(r1,'value')==1&~veg then //se desea calcular la atenuación por vegetación. veg=%t; if get(l1,'value')==[] then //no se ha seleccionado el tipo de polarización. buttondialog("Por favor, seleccione un tipo de polarización.","OK","info"); return; else bosque=get(e1,'string'); if bosque=="" then buttondialog("No ha introducido la distancia en metros de bosque atravesado. Por favor, introdúzcala y pulse el botón Capturar datos.","OK","info"); end while bosque=="" then bosque=get(e1,'string'); end [bosque,nerror]=evstr(bosque); if nerror<>0 then //tipo datos incorrecto buttondialog("El tipo de dato de bosque atravesado es incorrecto. Por favor, introdúzcalo de nuevo.","OK","info"); set(e1,'String',"") return; else //tipo datos correcto if bosque<0|bosque>dKm*1000 then //número de metros de bosque incorrecto. buttondialog("La distancia en metros de bosque atravesado es incorrecta. Por favor, introdúzcala de nuevo.","OK","info"); return; end end end

153

APÉNDICE: CÓDIGO FUENTE DE SCILAB

end if get(r2,'value')==1&~gas then gas=%t; if get(l2,'value')==[] then //no se ha seleccionado la densidad de vapor de agua. buttondialog("Por favor, seleccione un valor de densidad de vapor de agua.","OK","info"); return; end end if get(r3,'value')==1&~lluv then lluv=%t; if get(l3,'value')==[] then //no se ha seleccionado el tiempo p% de lluvia. buttondialog("Por favor, seleccione un valor de tiempo p% de lluvia.","OK","info"); return; else if get(r1,"value")==1 then //si se seleccionó la atenuación por vegetación, entonces, ya se tiene un valor de la polarización. if get(l4,'value')<>[] then //si se ha seleccionado la polarización en el apartado de atenuación por lluvia. if get(l4,'value')<>get(l1,'value') then //no coinciden los dos valores de la polarización. buttondialog("Se han introducido dos valores contradictorios en la polarización. Por favor, introduzca un único valor.","OK","info"); return; end else //no se ha seleccionado la polariación en el apartdo de atenuación por lluvia. buttondialog("No se ha introducido la polarización en el apartado de atenuación por lluvia.\nComo sí se hizo en el apartado de atenuación por vegetación, se tomará el valor de la polarización de ahí.","OK","info"); get(l4,'value')=get(l1,'value'); end else //no se tiene la polarización con antelación. if get(l4,'value')==[] then //no se ha seleccionado el tipo de polarización. buttondialog("Por favor, seleccione un tipo de polarización.","OK","info"); return; end end end end set(r4,'value','1'); endfunction function perdidas2() //calcula la pérdidas producidas por la vegetación , gases y vapores atmosféricos y/o lluvia. Aveg=0; Agas=0; Alluv=0; fGHz=fMHz/1000; set(r5,'value','0'); //Atenuación por vegetación. if get(r1,"value")==1 then gammav=0; //la frecuencia está comprendida entre 30MHz y 30GHz. Atespecifv=[0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 2 3 4 5 6 7 8 9 10 20 30;... 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 4 6;... 0.02 0.023 0.029 0.031 0.033 0.039 0.041 0.043 0.07 0.09 0.11 0.13 0.14 0.17 0.18 0.19 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 4 6]; Atespecifv=Atespecifv';

154

APÉNDICE: CÓDIGO FUENTE DE SCILAB

if get(l1,"value")==1 then //si el valor introducido por el ususario es de polarización horizontal. j=2; else //si el valor introducido por el usuario es de polarización vertical. j=3; end distbosque=eval(get(e1,"string")); for i=1:28 if Atespecifv(i,1)==fGHz then gammav=Atespecifv(i,j); break; end end if gammav==0 then //Si no está en la tabla se interpola logarítmicamente. cont=1; while Atespecifv(cont,1)<fGHz cont=cont+1; end gammav=10^(-((log10(Atespecifv(cont,1))-log10(fGHz))*(log10(Atespecifv(cont,j))-log10(Atespecifv(cont-1,j)))/(log10(Atespecifv(cont,1))-log10(Atespecifv(cont-1,1))))+log10(Atespecifv(cont,j))); end Aveg=gammav*distbosque; end //Atenuación por gases y vapores atmosféricos. if get(r2,"value")==1 then if fGHz>10 then //sólo tiene importancia cuando la frecuencia es mayor de 10GHz. //modificar select get(l2,"value") //lee el valor de la densidad de vapor de agua introducida por el usuario. En España tiene un valor comprendido en el rango [7.5,10]. case 1 then dva=7.5; case 2 then dva=9; case 3 then dva=10; end //Recomendación ITU-R-P.676. Ecuaciones en continuo ajuste. //Aproximación de gammao para f<=57GHz gammao=(7.2/(fGHz^2+0.34)+0.62/((54-fGHz)^2+0.83))*fGHz^2*10^(-3); //Aproximación para gammaw; ecuaciones en continuo cambio. eta1=0.955+0.006*dva; eta2=0.735+0.0353*dva; gammaw=(3.98*eta1/((fGHz-22.235)^2+9.42*eta1^2)*(1+((fGHz-22)/(fGHz+22))^2)+11.96*eta1/((fGHz-183.31)^2+11.14*eta1^2)+0.081*eta1/((fGHz-321.226)^2+6.29*eta1^2)+... 3.66*eta1/((fGHz-325.153)^2+9.22*eta1^2)+25.37*eta1/(fGHz-380)^2+17.4*eta1/(fGHz-448)^2+844.6*eta1/(fGHz-557)^2*(1+((fGHz-557)/(fGHz+557))^2)+... 290*eta1/(fGHz-752)^2*(1+((fGHz-752)/(fGHz+752))^2)+83328*eta2/(fGHz-1780)^2*(1+((fGHz-1780)/(fGHz+1780))^2))*fGHz^2*dva*10^(-4); Agas=(gammao+gammaw)*dKm; else buttondialog("La atenuación por gases y vapores atmosféricos sólo tiene importancia cuando la frecuencia es mayor de 10GHz.","OK","info"); end end //Atenuación por lluvia. if get(r3,"value")==1 then if fGHz>6 then

155

APÉNDICE: CÓDIGO FUENTE DE SCILAB

//sólo tiene importancia cuando la frecuencia es mayor que 6GHz. select get(l3,"value") //lee el valor del tiempo en tanto por ciento de lluvia introducido por el usuario. case 1 then p=0.01; case 2 then p=0.05; case 3 then p=0.07; end R001=42; //Correspondiente a la zona geográfica en estudio. d0=35*exp(-0.015*R001); Lef=dKm/(1+dKm/d0); Atespeciflluv=[6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30;... 0.0007056 0.001915 0.004115 0.007535 0.01217 0.01772 0.02386 0.03041 0.03738 0.04481 0.05282 0.06146 0.07078 0.08084 0.09164 0.1032 0.1155 0.1286 0.1425 0.1571 0.1724 0.1884 0.2051 0.2224 0.2403;... 1.5900 1.4810 1.3905 1.3155 1.2571 1.2140 1.1825 1.1586 1.1396 1.1233 1.1086 1.0949 1.0818 1.0691 1.0568 1.0447 1.0329 1.0214 1.0101 0.9991 0.9884 0.9780 0.9679 0.9580 0.9485;... 0.0004878 0.001425 0.003450 0.006691 0.01129 0.01731 0.02455 0.03266 0.04126 0.05008 0.05899 0.06797 0.07708 0.08642 0.09611 0.1063 0.1170 0.1284 0.1404 0.1533 0.1669 0.1813 0.1964 0.2124 0.2291;... 1.5728 1.4745 1.3797 1.2895 1.2156 1.1617 1.1216 1.0901 1.0646 1.0440 1.0273 1.0137 1.0025 0.9930 0.9847 0.9771 0.9700 0.9630 0.9561 0.9491 0.9421 0.9349 0.9277 0.9203 0.9129]; Atespeciflluv=Atespeciflluv'; //Atenuación específica por lluvia para frecuencias comprendidas entre 6GHz y 30GHz (rango de estudio que aquí se considera). if get(l4,"value")==1 then //si el valor introducido por el ususario es de polarización horizontal. j=2; else //si el valor introducido por el usuario es de polarización vertical. j=3; end k=0; for i=1:25 if Atespeciflluv(i,1)==fGHz then k=Atespeciflluv(i,j); alfa=Atespeciflluv(i,j+2); break; end end //Si no está en la tabla, se interpola linealmente alfa y, logarítmicamente, la frecuencia y k. if k==0 then cont=1; while Atespeciflluv(cont,1)<fGHz cont=cont+1; end k=10^(-((log10(Atespeciflluv(cont,1))-log10(fGHz))*(log10(Atespeciflluv(cont,j))-log10(Atespeciflluv(cont-1,j)))/(log10(Atespeciflluv(cont,1))-log10(Atespeciflluv(cont-1,1))))+log10(Atespeciflluv(cont,j))); alfa=-((log10(Atespeciflluv(cont,1))-log10(fGHz))*(Atespeciflluv(cont,j+2)-Atespeciflluv(cont-1,j+2))/(log10(Atespeciflluv(cont,1))-log10(Atespeciflluv(cont-1,1))))+Atespeciflluv(cont,j+2); end gamma001=k*((R001)^(alfa)); A001=gamma001*Lef; if p==0.01 then Alluv=A001; else Alluv=A001*0.12*p^(-(0.546+0.043*log10(p))); end

156

APÉNDICE: CÓDIGO FUENTE DE SCILAB

else buttondialog("La atenuación por lluvia sólo tiene importancia cuando la frecuencia es mayor que 6GHz.","OK","info"); end end set(r5,'value','1'); Avegstr=string(Aveg); Agasstr=string(Agas); Alluvstr=string(Alluv); set(t6,"string",Avegstr); set(t7,"string",Agasstr); set(t8,"string",Alluvstr); disp('Atenuación por vegeración (dB):') disp(Aveg) disp('Atenuación por gases y vapores atmosféricos (dB):') disp(Agas) disp('Atenuación por lluvia (dB):') disp(Alluv) endfunction

157

BIBLIOGRAFÍA

BIBLIOGRAFÍA

[1] Transmisión por radio

José María Hernando Rábanos

Editorial universitaria Ramón Areces, 5ª Edición, 2006.

[2] The mobile radio propagation channel

J. D. Parsons

London Pentech Press, 1994.

[3] Radio system design for telecomunications

Roger L. Freeman

New York [etc.] John Wiley & Sons, 1997

[4] Recomendaciones UIT-R P.310, 341, 453, 525, 526, 527, 530, 676, 833, 834, 836,

837, 838, 840, 1510. Serie P: Propagación de las ondas radioeléctricas.

Versiones vigentes en la fecha de comienzo de este Proyecto Fin de Carrera: Enero de 2007.

http://www.itu.int/rec/R-REC-P/e

[5] Tema 7: Radioprogación. Transparencias de la asignatura radiación y radiocomunicación

J.J Murillo-Fuentes

Universidad de Sevilla, 2005.

http://www.personal.us.es/murillo/docente/radio/RadioPrincipal.htm

[6] Tema 1: Propagación

Open Course Ware

Rafael Herradón Díez

Universidad Politécnica de Madrid, 2007.

http://gea.gate.upm.es/teoria-de-la-senal-y-comunicaciones-1/radiocomunicacion/contenidos/presentaciones/propagacion-07.pdf/view

[7] Radiación y Propagación

Apuntes y Transparencias

M. Sierra Castañer, J. L. Besada, L. de Haro.

Universidad Politécnica de Madrid, 2004.

http://www.gr.ssr.upm.es/rdpr/transparencias.html

[8] Radioenlaces Terrenales y Vía Satélite

Universidad de Vigo

158

BIBLIOGRAFÍA

http://www.grp.tsc.uvigo.es/rtvs/

[9] Características de la atmósfera

Universidad Nacional de Rosario, República Argentina

http://www.eie.fceia.unr.edu.ar/ftp/Antenas%20y%20Propagacion/ApBandas_Uso_Propagacion.pdf

[10] Cálculo de la atenuación por lluvia en un radioenlace

Francisco Ramón Pascual

http://www.radioptica.com/Radio/lluvia.asp?pag=3

[11] Free/Open Source software: an alternative for engineering students

Paulo S. Motta Pires, David A. Rogers

Frontiers in Education 2002, Boston

http://fie.engrng.pitt.edu/fie2002/index.htm

[12] Software Libre

http://es.wikipedia.org/wiki/Software_libre

[13] Código Abierto

http://es.wikipedia.org/wiki/C%C3%B3digo_abierto

[14] Pronunciamiento PLUG – Software Libre

Peruvian Linux User Group

http://www.linux.org.pe/softwarelibre/pronuncia.php

[15] Scilab Home Page

http://www.scilab.org/

[16] Parque natural Sierra de Grazalema

Consejería de Medio Ambiente

Junta de Andalucía

http://www.juntadeandalucia.es/medioambiente/site/web/menuitem.a5664a214f73c3df81d8899661525ea0/?vgnextoid=cd7b1efbae625010VgnVCM1000000624e50aRCRD

[17] Cartoteca

Instituto Geográfico Nacional

Ministerio de Fomento

http://www.ign.es/ign/es/IGN/cartoteca_MapTopo.jsp

159