#include "mex.h"
void timestwo(double y[], double x[])
{ y[0]=2.0*x[0]; }

void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
	double *x, *y;
	int mrows, ncols;
	/* Controlla il numero corretto di argomenti*/
	if (nrhs!=1) {
		mexErrMsgTxt("Viene richiesto solo un input."); }
	else if (nlhs>1) {
		mexErrMsgTxt("Troppi argomenti per l'output."); }
	/* L'input deve essere un double scalare non complesso*/
	mrows = mxGetM(prhs[0]);
	ncols = mxGetN(prhs[0]);
	if (!mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) || !(mrows == 1 && ncols == 1)) {
		mexErrMsgTxt("L'input deve essere un double scalare non complesso."); }
	/* Crea la matrice per l'argomento di output */
	plhs[0] = mxCreateDoubleMatrix(mrows,ncols,mxREAL);
	/*Assegna puntatori per ogni input e output */
	x = mxGetPr(prhs[0]);
	y = mxGetPr(plhs[0]);
	/*Chiama la subrutine timestwo*/
	timestwo(y,x);
	}

	
	