fminsearch for 2 inputs

I have my function f(TH,R) = @(TH,R) (abs((sqrt(2)/(81*sqrt(pi))).*(6.*R-R.^2).*exp(-R./3).*cos(TH))).^2
how would i set up another function to satisfy fminsearch while initial guess (0,1) and (pi,1)

Answers (2)

f2 = @(THR) F(THR(1), THR(2))
fminsearch(f2, [0 1])

1 Comment

well matlab gave me an error on this "ubscript indices must either be real positive integers or logicals"
this happened earlier when i tried to define function handle

Sign in to comment.

KSSV
KSSV on 7 Nov 2017
fun = @(x) (abs((sqrt(2)/(81*sqrt(pi))).*(6.*x(1)-x(1).^2).*exp(-x(1)./3).*cos(x(2)))).^2 ;
x = fminsearch(fun,[0 1]) ;

2 Comments

what if I'm trying to find the maximum? also it said Maximum number of function evaluations has been exceeded, current function value is 0.000
nvm i figured it out, thanks !

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 7 Nov 2017

Commented:

on 7 Nov 2017

Community Treasure Hunt

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

Start Hunting!