Fitting a function with constraints
Hi
I am currently struggling to fit a 2nd order polynomial function with specific constraints.
I have an external script that tells me wether the polynomial function is ascending, descending or u-shaped.
Therefore I’ve made a constraints (using the "fit" command) for the x^2 part to only be positive because I can only use downwards curves.
This is my current formula:
[p,gof] = fit(x,y,’poly2′,’lower’,[0,-inf,-inf],’normalize’,’on’)
Now I need to give specific constraint for each shape:
ascending: The minimum y-value must be at the first x-value (ymin = xmin)
descending: The minimum y-value must be at the last x-value (ymin = xmax)
U-curve: The minimum y-value must be in between the first and last x-value (xmin < ymin < xmax)Hi
I am currently struggling to fit a 2nd order polynomial function with specific constraints.
I have an external script that tells me wether the polynomial function is ascending, descending or u-shaped.
Therefore I’ve made a constraints (using the "fit" command) for the x^2 part to only be positive because I can only use downwards curves.
This is my current formula:
[p,gof] = fit(x,y,’poly2′,’lower’,[0,-inf,-inf],’normalize’,’on’)
Now I need to give specific constraint for each shape:
ascending: The minimum y-value must be at the first x-value (ymin = xmin)
descending: The minimum y-value must be at the last x-value (ymin = xmax)
U-curve: The minimum y-value must be in between the first and last x-value (xmin < ymin < xmax) Hi
I am currently struggling to fit a 2nd order polynomial function with specific constraints.
I have an external script that tells me wether the polynomial function is ascending, descending or u-shaped.
Therefore I’ve made a constraints (using the "fit" command) for the x^2 part to only be positive because I can only use downwards curves.
This is my current formula:
[p,gof] = fit(x,y,’poly2′,’lower’,[0,-inf,-inf],’normalize’,’on’)
Now I need to give specific constraint for each shape:
ascending: The minimum y-value must be at the first x-value (ymin = xmin)
descending: The minimum y-value must be at the last x-value (ymin = xmax)
U-curve: The minimum y-value must be in between the first and last x-value (xmin < ymin < xmax) curve fitting MATLAB Answers — New Questions