## how do you get the max y value in an fplot?

### Cameron Ernest (view profile)

on 17 Jun 2019
Latest activity Edited by Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 17 Jun 2019
How would I find the max y value in the following fplot
mu = @(theta) (sind(theta)/(1.8925 + cosd(theta)));
fplot(mu,[0 180]);

### Tags

on 17 Jun 2019

h = fplot(...);
MAX = max(h.YData)

### dpb (view profile)

on 17 Jun 2019

Look at the documentation and see what else you can do with fplot...
fp=fplot(mu,[0 100]);
[mxMu,imx]=max(fp.YData); % max, location
NB: Above is the maximum of the calculated points, not necessarily the functional maximum.
ADDENDUM: To avoid the warning message from fplot write your function with the "dot" operator ./ instead of just / ### Stephen Cobeldick (view profile)

on 17 Jun 2019
Edited by Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 17 Jun 2019

If you actually want to find the numerical solution (and not just whatever fplot happens to have calculated) then you can trivially use fminsearch:
>> fun = @(theta) (sind(theta)./(1.8925 + cosd(theta)));
>> xm = fminsearch(@(t)-fun(t),100)
xm =
121.9
>> ym = fun(xm)
ym =
0.62239
And checking:
>> fplot(fun,[0,180])
>> hold on
>> plot(xm,ym,'*r') Star Strider

### Star Strider (view profile)

on 17 Jun 2019
[xm,fun_at_xm] = fminsearch(@(x)-fun(x),100)
xm =
121.9
fun_at_xm =
-0.62239