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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2019년 11월 12일

댓글:

2019년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by