#include "mex.h" #include "matrix.h" #include "stdlib.h" #include "math.h" void mexFunction(int nlhs, mxArray *plhs[], // Output variables int nrhs, const mxArray *prhs[]) // Input variables { if (nrhs != 4) mexErrMsgTxt ("Check your input parameters"); if( mxGetNumberOfElements(prhs[2]) != mxGetNumberOfElements(prhs[3])) { mexErrMsgTxt ("arrays need to be of same size!"); } int variables = *mxGetPr(prhs[0]); double inc = *mxGetPr(prhs[1]); double* x = (double *)mxCalloc(variables, sizeof(double)); //create solution array double* x_in = (double *)mxCalloc(variables, sizeof(double)); //input x double* y = (double *)mxCalloc(variables, sizeof(double)); //input y double** GA = (double **)mxCalloc(variables+1, sizeof(double*)); //create Gauss Array (GA) for (int i = 0; i <= variables; i++){ GA[i] = (double *)mxCalloc(variables+1, sizeof(double)); } for(int i=0;i= 0; i--) //back-substitution { //x is an array whose values correspond to the values of x,y,z.. x[i] = GA[i][variables]; //make the variable to be calculated equal to the rhs of the last equation for (int j = i + 1; j