Ι have a problem finding a minimum
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
I created a fuction by writting
function [y]=h(x)
y=(x^8+P(x))^2
end
and I saved it as h.m then I wrote
[x,fval]=fminsearch(h,[2,3])
and it says its error FYI P(x) is a polynomial which i created in the main file
4 comentarios
dpb
el 6 de En. de 2016
What's P? Undefined here...
dpb
el 6 de En. de 2016
And, may as well show us the whole session including the error, too...
joanna zappa
el 6 de En. de 2016
Walter Roberson
el 6 de En. de 2016
Duplicated by later http://uk.mathworks.com/matlabcentral/answers/262900-have-a-problem-finding-a-minimum which has an answer, so I am merging into that
Respuestas (2)
jgg
el 6 de En. de 2016
It looks like the issue is that you have not passed P into your function. You probably want something like this instead:
P=polyfit(X,Y.',7);
func = @(x)h(x,P);
[x,fval]=fminsearch(func,[2,3])
where you define in your h.m file
function [y]=h(x,P)
p = polyval(P,x);
y=(x^8+p)^2
end
Walter Roberson
el 6 de En. de 2016
0 votos
Answered in duplicate Question http://uk.mathworks.com/matlabcentral/answers/262900-have-a-problem-finding-a-minimum
It sure is easier when people do not ask duplicate questions...
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!