Hi Eugenio Caredda,
I understand that you are using the "gapolyfitn" function for polynomial fitting of simulation data from a servovalve's behavior, aiming to model pressure as a function of spool position and flow. You are facing the issue that simulation stops after the first generation.
I assume that your data ("simout_xs" for spool position, "simout_q" for flow, and "simout_p12" for differential pressure) is correctly formatted and ready for analysis.
To troubleshoot the issue you are facing you can consider the following steps:
- Algorithm Configuration: The stopping after the first generation might be due to the configuration of the options parameter in "gapolyfitn". Check the "options" for parameters like "PopulationSize", "MaxGenerations", causing the algorithm to stop prematurely.
- Result Interpretation and Visualization: After fitting, when you try to visualize the results, ensure you're plotting the dependent variable (pressure) against the predicted values correctly. Your loop for calculating item seems to aim at recreating the pressure values, but the plot command might be inverted. It should likely be "plot(indepvar, item1)" to match the independent variables with the calculated pressure values.
- Data Preparation: Ensure your independent variables (indepvar) and dependent variable (depvar) are correctly assigned. Your approach seems correct by setting "indepvar = [simout_xs simout_q]" and "depvar = simout_p12". This step is crucial for the algorithm to understand the relationship you're trying to model.
References for further assistance:
- Refer to the documentation of "gapolyfitn" to understand its parameters and expected input format: https://www.mathworks.com/matlabcentral/fileexchange/25499-gapolyfitn
- For understanding genetic algorithms and their parameters in MATLAB, refer the following documentation: https://www.mathworks.com/help/gads/genetic-algorithm.html
Hope this helps!