📄 biterrfast.c
字号:
/* Bit or symbol error rate calculator.
* July 08, 2003
* B. Nugroho */
#include "mex.h"
void bit_err(double num[], double rat[], double a[], double b[], int L)
{
int err = 0;
int i;
for(i=0; i<L; i++)
{
if(a[i] != b[i])
err++;
}
/* Return the total number of errors. */
num[0] = err;
/* Return the error ratio. */
rat[0] = err/L;
}
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
double *a,*b;
int K, L1, L2;
double *num, *rat;
/* Get the input vector length */
K = mxGetM(prhs[0]);
L1 = mxGetN(prhs[0]);
L2 = mxGetN(prhs[1]);
/* Check whether both vectors have the same length */
if( L1 != L2) {
mexErrMsgTxt("Vector length must be the same");
}
/* Check vector dimension */
if( K > 1) {
mexErrMsgTxt("Dimension must be (1,length)");
}
/* Create 1x1 matrix for return arguments */
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
/* Get the vectors value of the inputs a and b. */
a = mxGetPr(prhs[0]);
b = mxGetPr(prhs[1]);
/* Assign pointer to the output. */
num = mxGetPr(plhs[0]);
rat = mxGetPr(plhs[1]);
/* Call the subroutine */
bit_err(num,rat,a,b,L1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -