Could you help me please??

1 view (last 30 days)
Maruti Patil
Maruti Patil on 11 Sep 2015
Answered: Star Strider on 11 Sep 2015
Suppose I have a function
x1=2; x2=-2; x3=4;
Now I want to find the value of x (i.e x1 or x2 or x3) corresponding to Fmin Xmin=value of x corresponding to Fmin How to do this??

Accepted Answer

Star Strider
Star Strider on 11 Sep 2015
You have to make vectors out of them, then it works:
f = @(x) x.^3+2; % Changed ‘inline’ To Anonymous Function
x1=2; x2=-2; x3=4;
[Fmin,ix] = min([f(x1),f(x2),f(x3)]); % Vector Of ‘f(x)’
x = [x1 x2 x3]; % Vector Of ‘x’
xFmin = x(ix) % ‘argmin’

More Answers (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by