本学期移动通信课程中有关于Okumura-Hata模型的,所以自己动手写了一个!
以下编写的程序由于时间紧迫,可能会有一些错误或不足,恳请大家指正:
基本原理:
Okumura/Hata模型是以准平滑地形的市区作基准,其余各区的影响均以校正因子的形式出现。Okumura/Hata模型市区的基本传输损耗模式为:
Lbα(hm) + (44. 9 - 6. 55lghb)lgd (5)
Lb:市区准平滑地形电波传播损耗中值(dB)
f:工作频率(MHz)
hb基站天线有效高度(m)
hm移动台天线有效高度(m)
d :移动台与基站之间的距离(km)
α(hm)移动台天线高度因子
对于大城市,移动台天线高度因子为
(6)
当hm在1 5-4m之间,上面两式基本一致。
对于中小城市(除大城市以外的其它所有城市〉
α(hm) = (1 1 19f - 0. 7)hm一(1 56 19f - 0. 8) (7)
对于郊区
Lbs市区)-2[g(f/28)]2—5.4 dB (8)
对于开阔地
Lb市区)-4. 78(gf)2+18. 33Igf-40. 94 dB (9)= Lb (
原代码:
- #include <stdio.h>
- #include <math.h>
- #define SIZE 300
- #define TRUE 1
-
- typedef struct
- {
- int area;
-
- int city;
-
- double d;
-
- double f;
- double Hb;
- double Hm;
- double AHm;
-
- double Lb;
- }OH_PRA;
-
-
- OH_PRA data[SIZE];
- int Number=0;
-
-
-
- void InitOH();
- void RET();
- int read();
-
- void write();
- void ADD();
- double Aa(int city,double f,double Hm);
-
- double L(int area,double f,double d,double Hb,double AHm);
-
- void LIST();
-
-
- int main()
- {
- FILE *fp;
- int i=0;
- int choose=0;
- char yesorno;
- if( (fp=fopen("OH","rb"))!= 0)
- {
- Number=read();
-
- }
- else
- {
- printf("/n=========>提示:文件不存在,是否要创建一个?(y/n)/n");
- scanf("%c",&yesorno);
- if( yesorno=='y' )
- {
- fp=fopen("OH","wb");
- fclose(fp);
- }
- else
- {
- exit(0);
- }
- }
- system("cls");
- while(TRUE)
- {
- InitOH();
- scanf("%d",&choose);
- system("cls");
- switch(choose)
- {
- case 1:ADD();RET();break;
- case 2:LIST();RET();break;
- case 0:return;
- default:break;
- }
- fflush(stdin);
- getchar();
- system("cls");
- }
- return 0;
- }
- void InitOH()
- {
- printf("/t*************************************************************/n");
- printf("/t* */n");
- printf("/t* Okumura-Hata预测系统 */n");
- printf("/t* */n");
- printf("/t* [1] 增加预测值 [2] 查看预测值 */n");
- printf("/t* [0] 退出系统 */n");
- printf("/t*************************************************************/n");
- }
- void RET()
- {
- printf("/t===>按Enter键返回主菜单/n");
- }
- int read()
- {
- FILE *fp=NULL;
- int i=0;
- fp=fopen("OH","rb");
- while(fread(&data[i],sizeof(OH_PRA),1,fp))
-
-
- i++;
- fclose(fp);
- return i;
- }
- void write()
- {
- FILE *fp;
- fp=fopen("OH","ab+");
- fwrite(&data[Number],sizeof(OH_PRA),1,fp);
- fclose(fp);
- }
- void ADD()
- {
- printf("ADD a new dataum:/n");
- printf(">>input area(0,1,2):/n");
- scanf("%d",&data[Number].area);
- printf(">>input city(0,1):/n");
- scanf("%d",&data[Number].city);
- printf(">>input d(km):/n");
- scanf("%lf",&data[Number].d);
- printf(">>input f(MHz):/n");
- scanf("%lf",&data[Number].f);
- printf(">>input Hb(m):/n");
- scanf("%lf",&data[Number].Hb);
- printf(">>input Hm(m):/n");
- scanf("%lf",&data[Number].Hm);
- data[Number].AHm=Aa(data[Number].city,data[Number].f,data[Number].Hm);
- data[Number].Lb=L(data[Number].area,data[Number].f,data[Number].d,
- data[Number].Hb,data[Number].AHm);
- printf("the contents that you wanted to add is:/n");
- printf("area city/td/tf/tHb/tHm/tAHM/tLb/n");
- printf("%4d%5d/t%.2lf/t%.2lf/t%.2lf/t%.2lf/t%.2lf/t%.2lf/n",
- data[Number].area,data[Number].city,data[Number].d,data[Number].f,
- data[Number].Hb,data[Number].Hm,data[Number].AHm,data[Number].Lb);
- write();
- Number++;
- }
- double Aa(int city,double f,double Hm)
- {
- double AHm=0;
- switch(city)
- {
- case 0:AHm=(1.1*log10(f)-0.7)*Hm-1.56*log10(f)+0.8;break;
- case 1:
- if(f<=300)
- {
- AHm=8.29*((log10(1.54*Hm))*(log10(1.54*Hm)))-1.1;
- }
- else
- {
- AHm=3.2*((log10(11.75*Hm))*(log10(11.75*Hm)))-4.97;
- }
- break;
- default:break;
- }
- return AHm;
- }
- double L(int area,double f,double d,double Hb,double AHm)
- {
- double Lb=0,Lb0=0;
- Lb0=69.55+29.16*log10(f)-13.82*log10(Hb)-AHm+(44.9-6.55*log10(Hb))*log10(d);
- switch(area)
- {
- case 0:Lb=Lb0;break;
- case 1:Lb=Lb0-2*((log10(f/28))*(log10(f/28)))-5.4;break;
- case 2:Lb=Lb0-4.78*(log10(f)*log10(f))+18.33*log10(f)-40.98;break;
- default:break;
- }
- return Lb;
- }
- void LIST()
- {
- int i=0;
- printf("area city/td/tf/tHb/tHm/tAHM/tLb/n");
- for(i=0;i<Number;i++)
- {
- printf("%4d%5d/t%.2lf/t%.2lf/t%.2lf/t%.2lf/t%.2lf/t%.2lf/n",
- data[i].area,data[i].city,data[i].d,data[i].f,
- data[i].Hb,data[i].Hm,data[i].AHm,data[i].Lb);
- }
- }
-