Could you help me please??

1 回表示 (過去 30 日間)
Maruti Patil
Maruti Patil 2015 年 9 月 11 日
回答済み: Star Strider 2015 年 9 月 11 日
Suppose I have a function
f=inline('x^3+2');
x1=2; x2=-2; x3=4;
Fmin=min(f(x1),f(x2),f(x3))
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??

採用された回答

Star Strider
Star Strider 2015 年 9 月 11 日
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’

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by