I am trying to use the gapolyfitn function with data from a servovalve's simulink model. This is a sample script of the function used to fit a function, that uses the variables from indepvar and depvar (while my data are in the variables my_indepvar and my_depvar). My data, stored in the simout_* variables, represents differential pressure, flow and position of the spool of the servovalve, are time-based and are stored in the same way of the input of the example script (indepvar and depvar, respectively 1001x2 double and 1001x1double). Their values are in this range:
simout_xs -0.0016 , 0.0060
simout_q -3.04e-05 , 1.9e-04
simout_p12 -3.83e+06 , 1.72e+07
When I try to use my_deepvar with the indepvar data from the example script the genetic algorithm works, so it's able to fit the pressure data from simulink, but when I try to use my_indepvar the algorithm stops at the 1st generation, giving the warning "Duplicate data points have been detected and removed - corresponding values have been averaged".
indepvar = randMat([0.00001; 0.00001], [0.99999; 0.99999], [0; 0], 1001);
my_indepvar = [simout_xs simout_q];
depvar = sin(5 .* indepvar(:,1) .* indepvar(:,2));
options.SAVEFILE = [cd '\testsav.mat'];
[polymodel, Best, IndAll] = gapolyfitn(indepvar, depvar, maxTerms, maxPower, options);
[XI,YI] = meshgrid(0.00001:(0.9999-0.00001)/100:0.9999, 0.00001:(0.9999-0.00001)/100:0.9999);
[XI,YI,ZI] = griddata(indepvar(:,1),indepvar(:,2),depvar, XI, YI);
[XI,YI,ZI] = griddata(indepvar(:,1),indepvar(:,2),polyvaln(polymodel,indepvar), XI, YI);
alltmspolymodel = polyfitn(indepvar, depvar, maxPower)