📄 mrc.c
字号:
/* ============================================================================
Property of Freescale
Freescale Confidential Proprietary
Freescale Copyright (C) 2006 All rights reserved
----------------------------------------------------------------------------
$RCSfile: MRC.c.rca $
Tag $Name: $
$Revision: 1.2 $
$Date: Mon Oct 30 16:59:14 2006 $
Target Processor: Matlab
============================================================================ */
//#include "StarCoreMath.h"
#include <stdlib.h>
#include <math.h>
#include "Math_Funcs.h"
#include "mex.h"
#include "SBX_FPULSPK_MRC.c"
#include "prototype.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]
#define X6_IN prhs[5]
#define X7_IN prhs[6]
// 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]
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
/* Matlab input interface (not all might be used) */
double *x1r,*x2r,*x3r,*x3i,*x4r,*x5r,*x6r,*x7r;
//Matlab output interface (not all might be used)
double *Y1r,*Y1i,*Y2r,*Y3r,*Y4r,*Y5r;
typedef struct SlotMeasurement
{
unsigned short int usiRSSI;
unsigned short int usiCINR;
signed short int siFreqOff;
signed short int siTimeOff;
} t_FPULSlotMeasurement;
unsigned long int NAnt;
unsigned long int NDataC;
short int **pData;
t_FPULSlotMeasurement **pSMsr;
int i,j,k,l;
double *temp;
short int tempyr,tempyi,tempzr,tempzi;
/* Matlab input dimensions (not all might be used) */
unsigned long mx1,nx1;
unsigned long mx2,nx2;
unsigned long mx3,nx3;
unsigned long mx4,nx4;
unsigned long mx5,nx5;
unsigned long mx6,nx6;
unsigned long mx7,nx7;
/* Matlab output dimensions (not all might be used) */
unsigned long my1,ny1;
unsigned long my2,ny2;
unsigned long my3,ny3;
unsigned long my4,ny4;
unsigned long my5,ny5;
/* Check for proper number of arguments */
if (nlhs != 5)
{
mexErrMsgTxt("Error: 5 output argument required.");
}
if (nrhs != 7)
{
mexErrMsgTxt("Error: 7 input arguments required.");
}
/* Check the input format */
if ( !mxIsDouble(X1_IN) )
{
mexErrMsgTxt("Error: Input 1 data must be of class 'double'.");
}
if ( mxIsComplex(X1_IN) )
{
mexErrMsgTxt("Error: Input 1 data must not be complex.");
}
if ( (!mxIsDouble(X2_IN) || mxIsComplex(X2_IN)))
{
mexErrMsgTxt("Error: Input 2 data must not be complex of class 'double'.");
}
if ( (!mxIsDouble(X3_IN) || !mxIsComplex(X3_IN)))
{
mexErrMsgTxt("Error: Input 3 data must be complex of class 'double'.");
}
if ( (!mxIsDouble(X4_IN) || mxIsComplex(X4_IN)))
{
mexErrMsgTxt("Error: Input 4 data must not be complex of class 'double'.");
}
if ( (!mxIsDouble(X5_IN) || mxIsComplex(X5_IN)))
{
mexErrMsgTxt("Error: Input 5 data must not be complex of class 'double'.");
}
if ( (!mxIsDouble(X6_IN) || mxIsComplex(X6_IN)))
{
mexErrMsgTxt("Error: Input 6 data must not be complex of class 'double'.");
}
if ( (!mxIsDouble(X7_IN) || mxIsComplex(X7_IN)))
{
mexErrMsgTxt("Error: Input 7 data must NOT be complex of class 'double'.");
}
/* 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);
mx5=mxGetM(X5_IN); nx5=mxGetN(X5_IN);
mx6=mxGetM(X6_IN); nx6=mxGetN(X6_IN);
mx7=mxGetM(X7_IN); nx7=mxGetN(X7_IN);
// Get Data
x1r = mxGetPr(X1_IN);
x2r = mxGetPr(X2_IN);
x3r = mxGetPr(X3_IN);
x3i = mxGetPi(X3_IN);
x4r = mxGetPr(X4_IN);
x5r = mxGetPr(X5_IN);
x6r = mxGetPr(X6_IN);
x7r = mxGetPr(X7_IN);
NAnt = (unsigned long int) *x1r;
NDataC = (unsigned long int) *x2r;
//pData
pData = (short int**)malloc(sizeof(short int*) * mx3);
for( i = 0; i < mx3; i++){
pData[i] = (short int*)malloc(sizeof(short int) * nx3 * 2);
}
for (l=0;l<NAnt;l++) {
//mexPrintf("** %d", (int)l);
for (i=0;i<NDataC;i++){
j = 2*i + l;
pData[l][2*i] = (short int)x3r[j]; // ant l
pData[l][2*i+1] = (short int)x3i[j];
}
}
//t_FPULSlotMeasurement **pSMsr;
pSMsr = (struct SlotMeasurement **)malloc(sizeof(struct SlotMeasurement*) * NAnt);
for(i=0;i<NAnt;i++){
pSMsr[i] = (struct SlotMeasurement *)malloc(sizeof(struct SlotMeasurement));
}
for (i=0;i<NAnt;i++){
pSMsr[i]->usiRSSI = (unsigned short int)x4r[i];
pSMsr[i]->usiCINR = (unsigned short int)x5r[i];
pSMsr[i]->siFreqOff = (signed short int)x6r[i];
pSMsr[i]->siTimeOff = (signed short int)x7r[i];
}
SBX_FPULSPK_MRC(NAnt,NDataC,pData,pSMsr);
Y1_OUT = mxCreateNumericMatrix(1,48,mxDOUBLE_CLASS,mxCOMPLEX);
Y2_OUT = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS, mxREAL);
Y3_OUT = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS, mxREAL);
Y4_OUT = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS, mxREAL);
Y5_OUT = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS, mxREAL);
Y1r = (double*)mxGetPr(Y1_OUT); Y1i = (double*)mxGetPi(Y1_OUT);
Y2r = (double*)mxGetPr(Y2_OUT);
Y3r = (double*)mxGetPr(Y3_OUT);
Y4r = (double*)mxGetPr(Y4_OUT);
Y5r = (double*)mxGetPr(Y5_OUT);
for (i=0;i<NDataC;i++){
j = 2*i; k = 2*i+1;
Y1r[i] = (double)pData[0][j];
Y1i[i] = (double)pData[0][k];
}
Y2r[0] = (double)pSMsr[0]->usiRSSI;
Y3r[0] = (double)pSMsr[0]->usiCINR;
Y4r[0] = (double)pSMsr[0]->siFreqOff;
Y5r[0] = (double)pSMsr[0]->siTimeOff;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -