# how to calculate final minimum in for -loop?

1 回表示 (過去 30 日間)
Brian Kim 2017 年 10 月 17 日
コメント済み: Jan 2017 年 10 月 17 日
It is assumed that there are calculated values according to the each iterations.
if..
by for loop,
1st -> 31 14 min = 14
2nd -> 31 14 61 min = 14
3rd -> 31 14 61 74 min = 14
4th -> 31 14 61 74 10 min = 10
5th -> 31 14 61 74 10 2 min = 2
6th -> 31 14 61 74 10 2 50 min = 2
If the values are not less than 2 after 6th, it will be decided as minimum value 2.
How to write code that way?
##### 1 件のコメント表示 なし非表示 なし
Jan 2017 年 10 月 17 日
The description is not clear. Prefer to post the current code or provide the input data in valid Matlab syntax. Currently the readers have to guess too many details.
Actually all you need is the min() command and perhaps an if to consider "If the values are not less than 2 after 6th, it will be decided as minimum value 2". Please try it.

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

### 回答 (1 件)

KL 2017 年 10 月 17 日
I suppose this is a homework and you're not allowed to use in-built functions like min. If so, you have to read about
1. matrix indexing
2. and how loop control statements work
3. and then how conditional statements work
if you get an idea of how these things work, you can easily write a program. If you have problems or questions while you're at it, just write a comment here. Good luck!
##### 1 件のコメント表示 なし非表示 なし
Brian Kim 2017 年 10 月 17 日
but i don't know what I apply

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

### カテゴリ

Help Center および File Exchange루프와 조건문 についてさらに検索

### Community Treasure Hunt

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

Start Hunting!