How to find local minimum of fit polynomial
13 views (last 30 days)
I have some stock data (time and price).
I log the data, and then use fit function to fit a polynomial onto it
then i make a function f
This is shown in the three lines of code below
date_log10 = log10(datenum(T2.Time)); price_log10 = log10(T2.Close);
[f_mdl,gof,output] = fit(date_log10,price_log10,'poly1','Normalize','on','Robust','Bisquare');
f(j) = 10.^f_mdl(log10(datenum(T2.Time(end))));
My question is, how to i now find the local minimum of this function f?
I was thinking i would use fminsearch, but just unsure how i would make use of that.
Image Analyst on 30 Apr 2022
I use polyfit() instead of fit(). Have you gotten a fitted y value vector yet? If so, just use min
miny = min(yFitted(index1 : index2))
Walter Roberson on 30 Apr 2022
poly1 is of the form a*x+b for some model parameters a and b. The minimum of a straight line is:
- at the lower bound of x if a is positive
- at the upper bound of x if a is negative