atenuacion_fibra.c

来自「matlab在通信原理中的应用」· C语言 代码 · 共 387 行

C
387
字号
/*
 * MATLAB Compiler: 3.0
 * Date: Wed Apr 07 23:58:18 2004
 * Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
 * "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
 * "array_indexing:on" "-O" "optimize_conditionals:on" "-S" "-W" "simulink"
 * "-L" "C" "-t" "-T" "link:mex" "libmatlbmx.mlib" "atenuacion_fibra" 
 */
#include "atenuacion_fibra.h"
#include "gcs.h"
#include "libmatlbm.h"
#include "num2str.h"
#include "str2num.h"
#include "warndlg.h"

static mxChar _array1_[10] = { 'D', 'i', 's', 't', 'M',
                               'a', 'x', 'R', 'e', 'p' };
static mxArray * _mxarray0_;

static mxChar _array3_[6] = { 'l', 'a', 'm', 'b', 'd', 'a' };
static mxArray * _mxarray2_;

static mxChar _array5_[6] = { 'N', 'c', 'o', 'n', 'e', 'c' };
static mxArray * _mxarray4_;

static mxChar _array7_[9] = { 'L', 'o', 'n', 'g', 'T', 'r', 'a', 'm', 'o' };
static mxArray * _mxarray6_;

static mxChar _array9_[10] = { 'S', 'h', 'o', 'r', 't',
                               '_', 'H', 'a', 'u', 'l' };
static mxArray * _mxarray8_;

static mxChar _array11_[4] = { '1', '3', '1', '0' };
static mxArray * _mxarray10_;
static mxArray * _mxarray12_;
static mxArray * _mxarray13_;

static mxChar _array15_[4] = { '1', '5', '5', '0' };
static mxArray * _mxarray14_;
static mxArray * _mxarray16_;

static mxChar _array18_[9] = { 'L', 'o', 'n', 'g', '_', 'H', 'a', 'u', 'l' };
static mxArray * _mxarray17_;
static mxArray * _mxarray19_;
static mxArray * _mxarray20_;
static mxArray * _mxarray21_;
static mxArray * _mxarray22_;
static mxArray * _mxarray23_;

static mxChar _array25_[5] = { 'P', 'a', 'r', 'a', ' ' };
static mxArray * _mxarray24_;

static mxChar _array27_[3] = { ' ', 'a', ' ' };
static mxArray * _mxarray26_;

static mxChar _array29_[56] = { 'n', 'm', ',', ' ', 'l', 'a', ' ', 'l',
                                'o', 'n', 'g', 'i', 't', 'u', 'd', ' ',
                                'm', 'a', 'x', 'i', 'm', 'a', ' ', 'd',
                                'e', ' ', 'r', 'e', 'g', 'e', 'n', 'e',
                                'r', 'a', 'c', 'i', 'o', 'n', ' ', 'd',
                                'e', ' ', 'e', 's', 't', 'a', ' ', 'f',
                                'i', 'b', 'r', 'a', ' ', 'e', 's', ' ' };
static mxArray * _mxarray28_;

static mxChar _array31_[64] = { ' ', 'K', 'm', 's', '.', ' ', 'D', 'e',
                                'b', 'e', 's', ' ', 'c', 'o', 'l', 'o',
                                'c', 'a', 'r', ' ', 'u', 'n', ' ', 'r',
                                'e', 'g', 'e', 'n', 'e', 'r', 'a', 'd',
                                'o', 'r', ' ', 'y', ' ', 'o', 't', 'r',
                                'o', ' ', 't', 'r', 'a', 'm', 'o', ' ',
                                'd', 'e', ' ', 'f', 'i', 'b', 'r', 'a',
                                ' ', 'o', 'p', 't', 'i', 'c', 'a', '.' };
static mxArray * _mxarray30_;

static mxChar _array33_[16] = { 'A', 'v', 'i', 's', 'o', ' ', 'I', 'm',
                                'p', 'o', 'r', 't', 'a', 'n', 't', 'e' };
static mxArray * _mxarray32_;

static mxChar _array35_[17] = { 'S', 'i', 'm', 'u', 'l', 'a', 't', 'i', 'o',
                                'n', 'C', 'o', 'm', 'm', 'a', 'n', 'd' };
static mxArray * _mxarray34_;

static mxChar _array37_[4] = { 'S', 't', 'o', 'p' };
static mxArray * _mxarray36_;
static mxArray * _mxarray38_;
static mxArray * _mxarray39_;
static mxArray * _mxarray40_;

void InitializeModule_atenuacion_fibra(void) {
    _mxarray0_ = mclInitializeString(10, _array1_);
    _mxarray2_ = mclInitializeString(6, _array3_);
    _mxarray4_ = mclInitializeString(6, _array5_);
    _mxarray6_ = mclInitializeString(9, _array7_);
    _mxarray8_ = mclInitializeString(10, _array9_);
    _mxarray10_ = mclInitializeString(4, _array11_);
    _mxarray12_ = mclInitializeDouble(15.0);
    _mxarray13_ = mclInitializeDouble(.35);
    _mxarray14_ = mclInitializeString(4, _array15_);
    _mxarray16_ = mclInitializeDouble(.2);
    _mxarray17_ = mclInitializeString(9, _array18_);
    _mxarray19_ = mclInitializeDouble(40.0);
    _mxarray20_ = mclInitializeDouble(80.0);
    _mxarray21_ = mclInitializeDouble(2.0);
    _mxarray22_ = mclInitializeDouble(0.0);
    _mxarray23_ = mclInitializeDouble(.4);
    _mxarray24_ = mclInitializeString(5, _array25_);
    _mxarray26_ = mclInitializeString(3, _array27_);
    _mxarray28_ = mclInitializeString(56, _array29_);
    _mxarray30_ = mclInitializeString(64, _array31_);
    _mxarray32_ = mclInitializeString(16, _array33_);
    _mxarray34_ = mclInitializeString(17, _array35_);
    _mxarray36_ = mclInitializeString(4, _array37_);
    _mxarray38_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
    _mxarray39_ = mclInitializeDouble(1.0);
    _mxarray40_ = mclInitializeDouble(10.0);
}

void TerminateModule_atenuacion_fibra(void) {
    mxDestroyArray(_mxarray40_);
    mxDestroyArray(_mxarray39_);
    mxDestroyArray(_mxarray38_);
    mxDestroyArray(_mxarray36_);
    mxDestroyArray(_mxarray34_);
    mxDestroyArray(_mxarray32_);
    mxDestroyArray(_mxarray30_);
    mxDestroyArray(_mxarray28_);
    mxDestroyArray(_mxarray26_);
    mxDestroyArray(_mxarray24_);
    mxDestroyArray(_mxarray23_);
    mxDestroyArray(_mxarray22_);
    mxDestroyArray(_mxarray21_);
    mxDestroyArray(_mxarray20_);
    mxDestroyArray(_mxarray19_);
    mxDestroyArray(_mxarray17_);
    mxDestroyArray(_mxarray16_);
    mxDestroyArray(_mxarray14_);
    mxDestroyArray(_mxarray13_);
    mxDestroyArray(_mxarray12_);
    mxDestroyArray(_mxarray10_);
    mxDestroyArray(_mxarray8_);
    mxDestroyArray(_mxarray6_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Matenuacion_fibra(int nargout_, mxArray * u);

_mexLocalFunctionTable _local_function_table_atenuacion_fibra
  = { 0, (mexFunctionTableEntry *)NULL };

/*
 * The function "mlfAtenuacion_fibra" contains the normal interface for the
 * "atenuacion_fibra" M-function from file
 * "c:\matlab6p5\work\softtdmv1.0\programa\sonet_sdh\atenuacion_fibra.m" (lines
 * 1-95). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfAtenuacion_fibra(mxArray * u) {
    int nargout = 1;
    mxArray * Atotal = NULL;
    mlfEnterNewContext(0, 1, u);
    Atotal = Matenuacion_fibra(nargout, u);
    mlfRestorePreviousContext(0, 1, u);
    return mlfReturnValue(Atotal);
}

/*
 * The function "mlxAtenuacion_fibra" contains the feval interface for the
 * "atenuacion_fibra" M-function from file
 * "c:\matlab6p5\work\softtdmv1.0\programa\sonet_sdh\atenuacion_fibra.m" (lines
 * 1-95). The feval function calls the implementation version of
 * atenuacion_fibra through this function. This function processes any input
 * arguments and passes them to the implementation version of the function,
 * appearing above.
 */
void mlxAtenuacion_fibra(int nlhs,
                         mxArray * plhs[],
                         int nrhs,
                         mxArray * prhs[]) {
    mxArray * mprhs[1];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: atenuacion_fibra Line: 1 Colum"
            "n: 1 The function \"atenuacion_fibra\" was called wi"
            "th more than the declared number of outputs (1)."),
          NULL);
    }
    if (nrhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: atenuacion_fibra Line: 1 Colu"
            "mn: 1 The function \"atenuacion_fibra\" was called "
            "with more than the declared number of inputs (1)."),
          NULL);
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 1 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 1; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 1, mprhs[0]);
    mplhs[0] = Matenuacion_fibra(nlhs, mprhs[0]);
    mlfRestorePreviousContext(0, 1, mprhs[0]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Matenuacion_fibra" is the implementation version of the
 * "atenuacion_fibra" M-function from file
 * "c:\matlab6p5\work\softtdmv1.0\programa\sonet_sdh\atenuacion_fibra.m" (lines
 * 1-95). It contains the actual compiled code for that M-function. It is a
 * static function and must only be called from one of the interface functions,
 * appearing below.
 */
/*
 * function Atotal=atenuacion_fibra(u)
 */
static mxArray * Matenuacion_fibra(int nargout_, mxArray * u) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(
          &_local_function_table_atenuacion_fibra);
    mxArray * Atotal = NULL;
    mxArray * Atenuacion = NULL;
    mxArray * ans = NULL;
    mxArray * alfa_c = NULL;
    mxArray * alfa_s = NULL;
    mxArray * Ntotal_emp = NULL;
    mxArray * alfa_n = NULL;
    mxArray * distancia_max = NULL;
    mxArray * long_total = NULL;
    mxArray * Ntotal_conec = NULL;
    mxArray * long_onda = NULL;
    mxArray * distancia = NULL;
    mxArray * curBlk = NULL;
    mxArray * b = NULL;
    mxArray * a = NULL;
    mclCopyArray(&u);
    /*
     * %==============================================
     * % atenuacion_fibra= Esta funcion permite calcular el valor de la Atenuacion Total de una
     * %                             Seccion Elemental de Fibra Optica:
     * %                                                            
     * %           Tx ____x______________x____ Rx
     * %         S                               R         
     * %              |--Seccion Elemental--|
     * %
     * %La Atenuacion sigue la siguiente ecuacion:
     * %
     * % Atotal=(1)*10^[-(alfa_n*long_total+alfa_s*Ntotal_emp+alfa_c*Ntotal_conec)/20]
     * %
     * %==============================================
     * %
     * %	AUTORES : Z. AGUI%O & D. STECKLER
     * %                       Universidad de Carabobo
     * %                       Valencia edo. Carabobo, VENEZUELA
     * %
     * %	FECHA     : Diciembre 2003
     * %	VERSION : 1.0
     * %
     * %==============================================
     * %	Realizado bajo MATLAB 6.5 Release 13/ Diciemdre 2003 (DZ)
     * %==============================================
     * %
     * [a b]=size(u);
     */
    mlfSize(mlfVarargout(&a, &b, NULL), mclVa(u, "u"), NULL);
    /*
     * curBlk=([gcs]);
     */
    mlfAssign(&curBlk, mlfGcs());
    /*
     * distancia=get_param(curBlk,'DistMaxRep');
     */
    mlfAssign(&distancia, mlfGet_param(mclVv(curBlk, "curBlk"), _mxarray0_));
    /*
     * long_onda=get_param(curBlk,'lambda');
     */
    mlfAssign(&long_onda, mlfGet_param(mclVv(curBlk, "curBlk"), _mxarray2_));
    /*
     * Ntotal_conec=str2num(get_param(curBlk,'Nconec'));
     */
    mlfAssign(
      &Ntotal_conec,
      mlfStr2num(NULL, mlfGet_param(mclVv(curBlk, "curBlk"), _mxarray4_)));
    /*
     * long_total=str2num(get_param(curBlk,'LongTramo'));
     */
    mlfAssign(
      &long_total,
      mlfStr2num(NULL, mlfGet_param(mclVv(curBlk, "curBlk"), _mxarray6_)));
    /*
     * %
     * %==============================================
     * %
     * %Selecciona el valor de la distancia maxima entre repetidores y el
     * %coeficiente de atenuacion
     * %
     * switch (distancia)
     */
    {
        mxArray * v_ = mclInitialize(mclVv(distancia, "distancia"));
        if (mclSwitchCompare(v_, _mxarray8_)) {
            /*
             * case 'Short_Haul'
             * switch (long_onda)
             */
            mxArray * v_0 = mclInitialize(mclVv(long_onda, "long_onda"));
            if (mclSwitchCompare(v_0, _mxarray10_)) {
                /*
                 * case '1310'
                 * distancia_max=15;
                 */
                mlfAssign(&distancia_max, _mxarray12_);
                /*
                 * alfa_n=.35;
                 */
                mlfAssign(&alfa_n, _mxarray13_);
            /*
             * case '1550'
             */
            } else if (mclSwitchCompare(v_0, _mxarray14_)) {
                /*
                 * distancia_max=15;
                 */
                mlfAssign(&distancia_max, _mxarray12_);
                /*
                 * alfa_n=0.20;
                 */
                mlfAssign(&alfa_n, _mxarray16_);
            /*
             * end
             */
            }
            mxDestroyArray(v_0);
        /*
         * case 'Long_Haul'
         */
        } else if (mclSwitchCompare(v_, _mxarray17_)) {
            /*
             * switch (long_onda)
             */
            mxArray * v_1 = mclInitialize(mclVv(long_onda, "long_onda"));
            if (mclSwitchCompare(v_1, _mxarray10_)) {
                /*
                 * case '1310'
                 * distancia_max=40;
                 */
                mlfAssign(&distancia_max, _mxarray19_);
                /*
                 * alfa_n=.35
                 */
                mlfAssign(&alfa_n, _mxarray13_);
                mclPrintArray(mclVv(alfa_n, "alfa_n"), "alfa_n");
            /*
             * case '1550'
             */
            } else if (mclSwitchCompare(v_1, _mxarray14_)) {
                /*
                 * distancia_max=80;
                 */
                mlfAssign(&distancia_max, _mxarray20_);
                /*
                 * alfa_n=0.20;
                 */
                mlfAssign(&alfa_n, _mxarray16_);
            /*
             * end
             */
            }
            mxDestroyArray(v_1);
        /*
         * end
         */
        }
        mxDestroyArray(v_);
    }
    /*
     * %
     * %Calculo del N

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?