if i have loop, for example
>> for i=1:3
a=i+2
end
the MATLAB will give me
a= 3,4,5
The question is: how to make matlab give me only the minimum value between those? which is 3
because i have many solutions and i want only the minimum one

 採用された回答

Stephen23
Stephen23 2019 年 11 月 12 日

0 投票

>> N = 3;
>> a = Inf;
>> for k = 1:N, a = min(a,k+2); end
>> a
a = 3

1 件のコメント

hassan alolaiwee
hassan alolaiwee 2019 年 11 月 12 日
thank you so much.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by