📄 demodmapper.c
字号:
/* ============================================================================
Property of Freescale
Freescale Confidential Proprietary
Freescale Copyright (C) 2005 All rights reserved
----------------------------------------------------------------------------
$RCSfile: DemodMapper.c.rca $
Tag $Name: $
$Revision: 1.2 $
$Date: Tue Oct 17 18:05:21 2006 $
Target Processor: Matlab
============================================================================ */
#include <stdlib.h>
#include <math.h>
#include "mex.h"
#include "SBX_FPULSPK_DemodMap.c"
#undef _ENTERPRISE_C_
#include "prototype.c"
#include "math_funcs.c"
// Input Arguments (not all might be used)
#define X1_IN prhs[0]
#define X2_IN prhs[1]
#define X3_IN prhs[2]
#define X4_IN prhs[3]
//#define X5_IN prhs[4]
// Output Arguments (not all might be used)
#define Y1_OUT plhs[0]
#define Y2_OUT plhs[1]
//#define Y3_OUT plhs[2]
//#define Y4_OUT plhs[3]
//#define Y5_OUT plhs[4]
/*In 48x1 192 int16 array (complex)
BlkSize 1x1 8 double array
mode 1x1 8 double array
DemapScale 1x1 2 char array
mOut_fixed 96x1 768 double array
*
signed long int SBX_FPULSPK_DemodMap(\
signed short int *psiIn,\
signed char *pcOut,\
unsigned long int uliInLen,\
unsigned char ucModType) */
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
/* Matlab input dimensions (not all might be used) */
unsigned long mx1,nx1;
unsigned long mx2,nx2;
unsigned long mx3,nx3;
unsigned long mx4,nx4;
/* Matlab output dimensions (not all might be used) */
unsigned long my1,ny1;
unsigned long my2,ny2;
unsigned long m,n;
unsigned long i;
signed short *pasiIn;
double *dp;
unsigned short *ausiDist;
//Others
double *temp3,*temp6,*temp7;
signed short int *temp1,*temp2;
signed short int *X1;
unsigned long int X3;
double *temp4;
unsigned char X4;
int status,buflen;
signed char *Y1;
double *Y2;
unsigned long int *temp5;
int temp10;
//mexPrintf("test1\n");
/* Check for proper number of arguments */
if ( nrhs!=4 )
{
mexErrMsgTxt("Error: Four input arguments required.");
}
else if (nlhs > 2)
{
mexErrMsgTxt("Error: Too many output arguments.");
}
/* Check the input format */
if ( !mxIsInt16(X1_IN) || !mxIsComplex(X1_IN))
{
mexErrMsgTxt("Error: input 1 must be complex of class 'int16'.");
}
if ( !mxIsDouble(X2_IN) || mxIsComplex(X2_IN))
{
mexErrMsgTxt("Error: input 2 must be real of class 'double'.");
}
if ( !mxIsDouble(X3_IN) || mxIsComplex(X3_IN))
{
mexErrMsgTxt("Error: input 3 must be real of class 'double'.");
}
if ( !mxIsChar(X4_IN) || mxIsComplex(X4_IN))
{
mexErrMsgTxt("Error: input 4 must be real of class 'char'.");
}
/* get input dimensions (not all might be used) */
mx1=mxGetM(X1_IN); nx1=mxGetN(X1_IN);
mx2=mxGetM(X2_IN); nx2=mxGetN(X2_IN);
mx3=mxGetM(X3_IN); nx3=mxGetN(X3_IN);
mx4=mxGetM(X4_IN); nx4=mxGetN(X4_IN);
/* collect data : X1*/
X1 = mxMalloc(sizeof(signed short int*)*mx1*nx1*2);
temp1 = (signed short int*)mxGetPr(X1_IN);
temp2 = (signed short int*)mxGetPi(X1_IN);
for(i=0;i<mx1*nx1;i++)
{
X1[2*i] = (signed short int) temp1[i] ;
X1[2*i+1] = (signed short int) temp2[i] ;
}
/* collect data : X3*/
X3 = (unsigned long int) (mx1*nx1);
//mexPrintf("X3 %d\n",(int) X3 );
/* collect data : X4*/
temp4 = (double*)mxGetPr(X3_IN);
X4 = (unsigned short int) (temp4[0]);
ny1=nx1;
temp10=(int)X4;
/*switch (X4) {
case 6:
my1=mx1*1*2;
case 4:
my1=mx1*2*2;
case 2:
my1=mx1*3*2;
}*/
my1=mx1*X4;
Y1 = mxMalloc(sizeof(char*)*my1*ny1);
status=SBX_FPULSPK_DemodMap((signed short int*)X1,Y1,X3,X4);
// outputs collection
Y1_OUT = mxCreateNumericMatrix(my1, ny1, mxDOUBLE_CLASS, mxREAL);
temp7 = (double*)mxGetPr(Y1_OUT);
for(i=0;i<my1*ny1;i++)
{
temp7[i] = (double) Y1[i];
}
Y2_OUT = mxCreateDoubleMatrix(1, 1, mxREAL);
Y2 = mxGetPr(Y2_OUT);
Y2[0] = (double)(my1*ny1);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -