I am trying to use the gapolyfitn to my data from a simulation of a servovalve's behavior.
The simulation stops after 1st generation, and I'm not very sure if I'm using the function right. I have 3 sets of data, that stands for spool position, differential pressure and flow. I want to represent pressure in function of the other two, so I placed my data in indepvar and the pressure data in depvar.
I'm using the example script in the function folder, that uses the function to fit the function sin(5xy) with the following code
indepvar = randMat([0.00001; 0.00001], [0.99999; 0.99999], [0; 0], 1000);
depvar= sin(5 .* indepvar(:,1) .* indepvar(:,2));
[polymodel, Best, IndAll] = gapolyfitn(indepvar, depvar, maxTerms, maxPower, options);
So as far as I understand it, randMat is creating a matrix 1000x2 as fake experimental data (so as points where the code will evaluate the function 5xy). So i tried to substitute randMat with my spool position and flow values from simulink simulation of the servovalve, and then to substitute the pressure data in the depvar variable as follow:
indepvar = [simout_xs simout_q];
But then I get the problem where it will only do one generation. I still got the polynomial coefficient though, so I write a function to multiply them with different flow and spool position
for tt=1:length(simout_xs)
iterm(ii)=polymodel.Coefficients(ii)*var(1)^polymodel.ModelTerms(ii,1)*var(2)^polymodel.ModelTerms(ii,2);
item(tt,ll)=item(tt,ll)+iterm(ii);
item(tt,ll)=-item(tt,ll);
and I though this should have tried to wrote the pressure graph of the new data, but instead is trying to represent spool position of new data, so I'm kinda confused if I'm doing things right or not