⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scramble_long.cpp

📁 用matlab程序实现WCDMA系统的仿真
💻 CPP
字号:
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "mex.h"
#include "ScrambleLong1.cpp"


#define	SEQUENCE_LENGTH	33554432	/* 2^25 */
#define CODE_LENGTH		38400
#define BUFFER_LENGTH	25
#define ARRAY_LENGTH	26
#define LOG2(arg) (log( (double) arg)/log(2))

#define OFFSET		16777232
#define COUNT1		16777199
#define MAX_CODE_NUMBER	16777215
#define NDIMS			2

void scramble_long(unsigned long, short int *, short int *);

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 scramble_long.cpp.  Supports that passing of one input parameter
* and one output parameter.  The input parameters is
*		code_number			Integer valued scalar between 0 and 16777215
*
* The one output parameter is 
*		scramble code		Complex valued vector that contains the scramble code
***************************************************************************************/
{
	unsigned long MX_code_number;
	int mrows,ncols;
	double dbl_code_number,fraction,integer_portion;
	short int *real_code, *imag_code;
	const int dims[]={CODE_LENGTH,1};

	// Check for the proper number of inupt and output argurments
	if (nrhs != 1) mexErrMsgTxt("\nExactly ONE input is required\n");
	else if (nlhs > 1) mexErrMsgTxt("\nToo many output arguements!  Only ONE is required\n");

	// The input must be a non_complex, scalar
	mrows = mxGetM(*prhs);
	ncols = mxGetN(*prhs);
	if ( !mxIsDouble(*prhs) || mxIsComplex(*prhs) || !(mrows ==1 && ncols ==1))
		mexErrMsgTxt("\nInput must be a noncomplex scalar\n");

	// The input must also be an integer
	dbl_code_number=mxGetScalar(*prhs);
	fraction=modf(dbl_code_number,&integer_portion);
	MX_code_number = (unsigned long) integer_portion;
	if (fraction != 0) mexErrMsgTxt("\nInput must be an integer\n");
	if (MX_code_number > MAX_CODE_NUMBER) 
		mexErrMsgTxt("\nInput must be less than or equal to 16777215\n");

	// Create integer array for scrambling code
/*	if ((real_code=(short int *) calloc(CODE_LENGTH,sizeof(short int )))==NULL)
	{
		printf("\nreal code array not allocated!--exiting\n");
		exit(-2);
	}

	if ((imag_code=(short int *) calloc(CODE_LENGTH,sizeof(short int )))==NULL)
	{
		printf("\nimag code array not allocated!--exiting\n");
		exit(-2);
	}

*/	
	*plhs = mxCreateNumericArray( NDIMS,dims,mxINT16_CLASS,mxCOMPLEX);
	real_code = (short int *) mxGetPr(*plhs);
	imag_code = (short int *) mxGetPi(*plhs);

	scramble_long(MX_code_number, real_code, imag_code);
}

⌨️ 快捷键说明

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