Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Ι have a problem finding a minimum
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2016년 1월 6일
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
답변 (2개)
jgg
2016년 1월 6일
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
댓글 수: 0
Walter Roberson
2016년 1월 6일
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...
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!