Find the minimum of a multivariable anonymous function + error message

Hello,
So I have a multivariable anonymous function in matlab, something in the realm of
y = @(A,h) totavg_pertime(A,h) + 3.5;
%totavg_pertime(A,h) is a long function expressed in terms of A and h
I tried to find the optimal values of A and h such that y is minimal by the following:
%guess A_i*, h_i*:
v0 = [1,1];
v = @(A,h) fminsearch(y(A,h),v0);
The program outputted an error message, "FUN must be a function, a valid character vector expression, or an inline function object." I thought 'y' is already a function??

답변 (1개)

Torsten
Torsten 2018년 11월 21일

0 개 추천

v = fminsearch(@(x)y(x(1),x(2)),v0);

카테고리

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

제품

릴리스

R2017b

질문:

2018년 11월 21일

답변:

2018년 11월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by