www.pudn.com > WCDMA.rar > GenWCDMAUplinkSignal.cpp
#include#include #include #include #include "mex.h" #include "GenUplinkSignal.cpp" void GenWCDMAUplinkSignal(double *,double *,double *,double *, double *,double *,unsigned ,double *,unsigned , unsigned ,double *,double *,unsigned ); void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) /*************************************************************************************** * void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) * * Copyright 2002 The Mobile and Portable Radio Research Group * * * Gateway function for GenRxRootRaisedCosine. Supports that passing of five input parameters * and one output parameter. The five input parameters are * CurrentChips Complex valued chipping sequence associated with current frame * PastChips Complex valued chipping sequence associated with preveious frame * FutureChips Complex valued chipping sequence associated with next frame * PulseShape Real valued vector containing pulse shape * SamplesPerChip Number of signal sample Points per chip * * The output parameter is * UplinkSignal Signal associated with current uplink frame (Current Chips_ ***************************************************************************************/ { double *mexPulseShape; double *mexRealSig,*mexImagSig; double *mexRealCurrentChips,*mexImagCurrentChips; double *mexRealPastChips,*mexImagPastChips; double *mexRealFutureChips,*mexImagFutureChips; int mexPulseLength,mexChipLength,mexSamplesPerChip; long int mexSignalLength; int mrows,ncols; double dbleScale,fraction,integer_portion; const mxArray *tprhs; //Check for the proper number of input and output arguments if (nrhs != 5) mexErrMsgTxt("\nExactly FIVE input arguemnts are required!!\n"); else if (nlhs != 1 ) mexErrMsgTxt("\nExactly ONE output arguement is required!!\n"); //First two Inputs must be vectors //Current Chip Sequence //Must be a double, complex, and a vector tprhs = *prhs; mrows = mxGetM(tprhs); ncols = mxGetN(tprhs); if ( !mxIsDouble(tprhs) || !mxIsComplex(tprhs) || (mrows ==1 && ncols ==1) || (mrows >1 && ncols >1)) mexErrMsgTxt("\nCurrent Chip Sequence must be a complex vector\n"); if (mrows > ncols) mexChipLength = mrows; else mexChipLength = ncols; mexRealCurrentChips = mxGetPr(tprhs); mexImagCurrentChips = mxGetPi(tprhs); //Past Chip Sequence //Must be a double, complex, and a vector tprhs = *(prhs+1); mrows = mxGetM(tprhs); ncols = mxGetN(tprhs); if ( !mxIsDouble(tprhs) || !mxIsComplex(tprhs) || (mrows ==1 && ncols ==1) || (mrows >1 && ncols >1)) mexErrMsgTxt("\nPast Chip Sequence must be a complex vector\n"); if (mrows > ncols) mexChipLength = mrows; else mexChipLength = ncols; mexRealPastChips = mxGetPr(tprhs); mexImagPastChips = mxGetPi(tprhs); //Next Chip Sequence //Must be a double, complex, and a vector tprhs = *(prhs+2); mrows = mxGetM(tprhs); ncols = mxGetN(tprhs); if ( !mxIsDouble(tprhs) || !mxIsComplex(tprhs) || (mrows ==1 && ncols ==1) || (mrows >1 && ncols >1)) mexErrMsgTxt("\nFuture Chip Sequence must be a complex vector\n"); if (mrows > ncols) mexChipLength = mrows; else mexChipLength = ncols; mexRealFutureChips = mxGetPr(tprhs); mexImagFutureChips = mxGetPi(tprhs); //Pulse Sphape //Must be a double, real and a vector tprhs = *(prhs+3); mrows = mxGetM(tprhs); ncols = mxGetN(tprhs); if ( !mxIsDouble(tprhs) || mxIsComplex(tprhs) || (mrows ==1 && ncols ==1) || (mrows >1 && ncols >1)) mexErrMsgTxt("\nPulse Shape must be a real vector\n"); if (mrows > ncols) mexPulseLength = mrows; else mexPulseLength = ncols; mexPulseShape = mxGetPr(tprhs); //Last Input must be a scalar //SamplesperChip tprhs = *(prhs+4); mrows = mxGetM(tprhs); ncols = mxGetN(tprhs); if ( !mxIsDouble(tprhs) || mxIsComplex(tprhs) || !(mrows ==1 && ncols ==1)) mexErrMsgTxt("\nSamplesperChip must be a scalar\n"); dbleScale=mxGetScalar(tprhs); fraction=modf(dbleScale,&integer_portion); if (integer_portion <= 0.0) mexErrMsgTxt("\nSamplesPerChip must be positive\n"); mexSamplesPerChip = (int) integer_portion; if (fraction != 0) mexErrMsgTxt("\nSamplesPerChip must be an integer\n"); //Determine Size of output array mexSignalLength = mexPulseLength + (mexSamplesPerChip*(mexChipLength-1)); //Allocate output Array *plhs = mxCreateDoubleMatrix(1,mexSignalLength,mxCOMPLEX); mexRealSig = mxGetPr(*plhs); mexImagSig = mxGetPi(*plhs); //Call WCDMA Uplink Signal Generator GenWCDMAUplinkSignal(mexRealCurrentChips,mexImagCurrentChips, mexRealPastChips,mexImagPastChips, mexRealFutureChips,mexImagFutureChips, (unsigned) mexChipLength,mexPulseShape, (unsigned) mexPulseLength,(unsigned) mexSamplesPerChip, mexRealSig,mexImagSig,(unsigned) mexSignalLength); }