b=5; x1=0; x2=0.5; x3=1; dx=0.5; % Initial values
syms xf=inline('(x^2)+(54/x)'); % Function
while x3<=b %Conditions
if f(x1)>=f(x2) && f(x2)<=f(x3) %Conditionsdisp('minima lies between x1 and x3')else x1=x2; x2=x3; x3=x2+dx; % Modified values of x1 x2 & x3 if above condition is not satisfied.
% from these values it should goto start point until conditions are satisfied
endend
MATLAB: Please help to rectify an error……(Error in while loop)
MATLABwhile loop
Best Answer