#include "mex.h"
#include "simulator.h"

void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
	 double usa, usb;
	 double *x_out, *y_out;

	/* Check the number of inputs and output arguments */
    if ( n_input==2 ) {
			 usa = *mxGetPr(input[0]);
			 usb = *mxGetPr(input[1]);
			pmsmsim_noreg_step(usa,usb);
      } 
    if ( n_input==1 ) {
		double Ww = *mxGetPr(input[0]);
		for (int i=0;i<125; i++){
		pmsmsim_step(Ww,0.0);
		}
	}

   output[0]= mxCreateDoubleMatrix(9, 1, mxREAL); 
	x_out= mxGetPr(output[0]);
	
	output[1]= mxCreateDoubleMatrix(6, 1, mxREAL); 
	y_out= mxGetPr(output[1]);
	
	pmsmsim_fill_xy(x_out,y_out);
  
}

