MATLAB: Find the solutions of h(x)=(x^8+P(x))^2 which give local minimum (fminsearch)…..any help

fminsearch

i dont know what function i have to write and also when i write xmin=fminsearch(…..) what i must write inside the space??

Best Answer

If P(x) is a 7-degree polynomial derived from polyfit:
p = randi(9, 1, 7); % Create Data (Polynomial Coefficients)
f = @(x,p) x.^8 + polyval(p,x).^2; % Function
x0 = 2; % Initial Estimate For ā€˜xā€™
[xmin,fval] = fminsearch(@(x)f(x,p), x0); % Find Minimum
You have likely gotten ā€˜pā€™ from something other than randi, but I had to create something to test the code.