fminsearch error regarding matrix dimensions

Hi
I am using fminsearch to minimize the following function:
a_d = 13.2414;
a_nd = 15.5107;
b_d = -1.4207;
b_nd = -1.9339;
Ft = 35;
funct = @(x)a_d*((2*Ft)/(x+1))+b_d+(a_nd*x*((2*Ft)/(x+1)))+b_nd;
[x,fval] = fminsearch(funct, [0, 10]);
But do get the following error:
Error using /
Matrix dimensions must agree.
Error in @(x)a_d*((2*Ft)/(x+1))+b_d+(a_nd*x*((2*Ft)/(x+1)))+b_nd
Error in fminsearch (line 191)
fv(:,1) = funfcn(x,varargin{:});
Error in Script (line 22)
[x,fval] = fminsearch(funct, [0, 10]);
What is the problem? Thanks!

 채택된 답변

Mischa Kim
Mischa Kim 2014년 7월 3일
편집: Mischa Kim 2014년 7월 3일

1 개 추천

MiauMiau, the function funct has only one dependent variable, x, correct? If so this needs to be reflected in the function call for fminsearch
[x,fval] = fminsearch(funct, 0);
With your function call
[x,fval] = fminsearch(funct, [0, 10]);
you assign starting values for a 2-vector, e.g. x1 and x2.

댓글 수: 3

Thanks, that sort of worked, I get:
>> Script
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -65036482218856192.000000
I want to restrict the x value where fmin is looking for the minima to [0,10] - how could I do that? I guess this would also solve the latest "error". thx!
Use instead
[x,fval] = fminbnd(funct,0,10)
MiauMiau
MiauMiau 2014년 7월 3일
prft, thx

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Optimization에 대해 자세히 알아보기

태그

질문:

2014년 7월 3일

댓글:

2014년 7월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by