MATLAB: How do i find max value of a two varible equation
max valuetwo varible equation
%equation X=-100*sin(t*omega)
omega=1:1:100
t=0:0.001:10
Best Answer
If you have a recent release, then you can use implicit expansion to calculate all combinations and find thet andomega that result in the maximum value. This will not find the true optimal values, but only the values allowed by your vectors. If you want to find the 'real' answers, you can use the second method (which only uses base functions, so no need for the curve fitting toolbox).
omega=1:1:100;
t=0:0.001:10;
X=-100*sin(t'*omega);
[r,c]=find(X==max(X(:)));
X_fun=@(t,omega) -100*sin(t*omega);
initialguess_t_omega=[7,13];
%invert the direction to use fminsearch to find the maximum
Best Answer