📄 flipbytes.c
字号:
/*FLIPBYTES.C Cmex function to flip the bytes of a given number or matrix. This function is usefull to read and write the Nanoscope file in the correct way. The calling syntax is: [Q] = flipbytes(R) Claudio October 2, 1994*/#include <math.h>#include "mex.h"/* Input Arguments */#define M_IN prhs[0]/* Output Arguments */#define M_OUT plhs[0]staticvoid flip( double pin[], double pout[], int s ){ unsigned short p; short q; int i; for(i=0; i<s;i++) { p=(short)pin[i]; q=p<<8 | p>>8; pout[i]=(double)q; } return;}void mexFunction( int nlhs, Matrix *plhs[], int nrhs, Matrix *prhs[] ){ double *pin; double *pout; unsigned int row,col; /* Check for proper number of arguments */ if (nrhs != 1) { mexErrMsgTxt("FLIPBYTES requires one input arguments."); } else if (nlhs > 1) { mexErrMsgTxt("FLIPBYTES requires one output argument."); } /* Check the dimensions of M_IN */ row = mxGetM(M_IN); col = mxGetN(M_IN); /* Create a matrix for the return argument */ M_OUT = mxCreateFull(row, col, REAL); /* Assign pointers to the various parameters */ pout = mxGetPr(M_OUT); pin = mxGetPr(M_IN); /* Do the actual computations in a subroutine */ flip(pin,pout,row*col); return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -