Hi Eugenio,
I understand that you are facing the warning message "Duplicate data points have been detected and removed - corresponding values have been averaged", while using the "gapolyfitn" function with the "my_indepvar" data.
The warning suggests that in your dataset "my_indepvar", there are rows with identical values. Removing duplicates and training the model on a clean and representative dataset, helps improve the accuracy on new, unseen data.
There are 3 ways to address this issue,
- Remove duplicates- you can use "unique" to remove rows with identical values for both "x" and "y" columns, as shown below.
uIndepvar = unique(indepvar, 'rows');
- Introduce randomness- you can randomly increase or decrease the corresponding values, to get rid of duplicates, as shown below.
rIndepvar = indepvar + randn(size(indepvar))/10000;
- Average duplicates- this is automatically done by the fitting algorithm if duplicates are present in the data(as suggested by the warning).
For more details, please refer to the following MATLAB documentations:
- https://www.mathworks.com/help/matlab/ref/double.unique.html
- https://www.mathworks.com/help/matlab/ref/randn.html
Hope this helps!
Best Regards,
Aryan Gupta