#include "mex.h"

void pol_fun (double *y, double x) {
	*y = 3.0*x*x + 2.0*x - 1; }
	
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
	double *y;
	double x;
	/*Crea una matrice 1x1 per l'argomento di ritorno*/
	plhs[0]=mxCreateDoubleMatrix(1,1,mxREAL);
	/*Prende il valore scalare per l'input x*/
	/*Nota: mxGetScalar ritorna un valore, non un puntatore-*/
	x=mxGetScalar(prhs[0]);
	/*Assegna un puntatore all'output.*/
	y = mxGetPr(plhs[0]);
	/*Chiama la subrutine pol_fun.*/
	pol_fun(y,x);
	}
	
	
