フィルターのクリア

Print certain values from an array with a condition

8 ビュー (過去 30 日間)
Rita Akonobi
Rita Akonobi 2020 年 9 月 28 日
コメント済み: Rita Akonobi 2020 年 9 月 28 日
Hi all Please I need help to complete this assignment.I have a function f(x)=x^2*exp(-x) and would like to print f(min) and the corresponding x tha gave that value. Please look at what I have done so far and help me identify why it't not printing
x=[0:0.07:5];
y=(x).^2.*exp(-x);
if y == min(y)
disp('min value of y =', num2str (y));
disp('x value for min y=', mum2str(x));
end

採用された回答

madhan ravi
madhan ravi 2020 年 9 月 28 日
ix = find(y == min(y));
fprintf('min value of y = %d\n', y(ix))
fprintf('x value for min y = %d\n', x(ix))
  3 件のコメント
madhan ravi
madhan ravi 2020 年 9 月 28 日
Replace it with whatever you want.
Rita Akonobi
Rita Akonobi 2020 年 9 月 28 日
ok thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by