How to separate a number in 5 in for loop

1 回表示 (過去 30 日間)
Andi Wang
Andi Wang 2018 年 10 月 4 日
コメント済み: Andi Wang 2018 年 10 月 4 日
Let’s say we have a for loop for y, y=0:10
the second for loop is x=0:y
I want x separate in 5 to each y
For example, for y=1, x1=0.2,x2=0.4....x5=1; for y=2,x1=0.4.....x5=2

採用された回答

Walter Roberson
Walter Roberson 2018 年 10 月 4 日
x1 = 0.2 * y;
x2 = 0.4 * y;
x3 = 0.6 * y;
x4 = 0.8 * y;
x5 = 1.0 * y;
But consider
x = (0.2:0.2:1) * y;
  1 件のコメント
Andi Wang
Andi Wang 2018 年 10 月 4 日
the second one helps me a lot, cause I may want to separate in more than 10.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by