首页 > 其他分享 >2.天线参数计算

2.天线参数计算

时间:2022-10-30 14:59:22浏览次数:40  
标签:Lam cout 天线 float 参数 计算 波长 er

#pragma warning(disable:4996)
#define _CRT_SECURE_NO_WARNINGS 1
const float c = 3e11;
#include <iostream>
using namespace std;

class Antenna
{
public:
    Antenna(float &f)
    {
        this->f = f;
        this->Lam = c / f;
        this->Lamquarter = this->Lam / 4;
    }
public:
    float Lam;//天线工作波长
    float Lamquarter;//天线工作四分之一波长
    float f;//天线工作的频率
};

class AntennaWG
{
public:
    AntennaWG(float &f,float &er)
    {
        this->f = f;
        this->er = er;
        this->Lam = c / f;
        this->Lamquarter = this->Lam / 4;
        this->Lamg = this->Lam / sqrt(this->er);
        this->Lamgquarter = this->Lamg / 4;
    }
public:
    float er;//介质板介电常数
    float Lam;//天线工作波长
    float Lamquarter;//四分之一的天线工作波长
    float Lamg;//天线导波波长
    float Lamgquarter;//四分之一的天线导波波长
    float f;//天线工作的频率
};

int main()
{
    while( 1 )
    {
        unsigned int project;//要计算的项目
        cout << "请输入你要计算的项目:" << endl;
        cout << "输入1计算自由空间波长及四分之一波长;" << endl;
        cout << "输入2计算导波波长和四分之一波长;" << endl;
        cin >> project;
        cout << endl;
        if( (project == 1) || (project == 2) )
        { 
            switch( project )
            {
                case 1:
                {
                    float f;//要计算的频率
                    cout << "输入天线的频率f:" << endl;
                    cin >> f;
                    cout << endl;
                    Antenna antenna(f);
                    cout << "天线的频率f:" << antenna.f << endl;
                    cout << "天线波长Lam = :" << antenna.Lam << endl;
                    cout << "天线的1/4波长Lamquarter = :" << antenna.Lamquarter << endl;
                    break;
                }

                case 2:
                {
                    float f;//要计算的频率
                    cout << "输入天线的频率f:" << endl;
                    cin >> f;
                    cout << endl;
                    float er;//介质板的介电常数
                    cout << "输入基板的相对介电常数er:" << endl;
                    cin >> er;
                    cout << endl;
                    AntennaWG antennaWG(f,er);
                    cout << "天线的频率f:" << antennaWG.f << endl;
                    cout << "输入基板的相对介电常数er:" << antennaWG.er << endl;
                    cout << "天线波长Lam = :" << antennaWG.Lam << endl;
                    cout << "天线的1/4波长Lamquarter = :" << antennaWG.Lamquarter << endl;
                    cout << "天线导波波长Lamg = :" << antennaWG.Lamg << endl;
                    cout << "天线的1/4导波波长Lamgquarter = :" << antennaWG.Lamgquarter << endl;

                    break;
                }
            }
        }
        else
        {
            cout << "输入错误" << endl;
            continue;
        }
    }

    return 0;
}

标签:Lam,cout,天线,float,参数,计算,波长,er
From: https://www.cnblogs.com/codemagiciant/p/16841274.html

相关文章