Last active
September 24, 2020 20:11
-
-
Save cristeab/8ce926c9994efb50b9e20946b0e176dc to your computer and use it in GitHub Desktop.
Simple function that performs in C++Quadrature Phase Shift Keying (QPSK) modulation using as inputs arrays from MATLAB and returning in MATLAB format the output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <itpp/itcomm.h> | |
| #include <itpp/itmex.h> | |
| using namespace itpp; | |
| void mexFunction(int n_output, mxArray *output[], int n_input, const mxArray *input[]) { | |
| // Check the number of inputs and output arguments | |
| if(n_output!=1) mexErrMsgTxt("Wrong number of output variables!"); | |
| if(n_input!=1) mexErrMsgTxt("Wrong number of input variables!"); | |
| // Convert input variables to IT++ format | |
| bvec input_bits = mxArray2bvec(input[0]); | |
| // - - - - - - - - - Start of routine - - - - - - - - - - - - - - | |
| cvec output_symbols; | |
| QPSK qpsk; | |
| output_symbols = qpsk.modulate_bits(input_bits); | |
| // - - - - - - - - - End of routine - - - - - - - - - - - - - - - | |
| // Create output vectors | |
| output[0] = mxCreateDoubleMatrix(1,output_symbols.size(), mxCOMPLEX); | |
| // Convert the IT++ format to Matlab format for output | |
| cvec2mxArray(output_symbols, output[0]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment