How to separate a number in 5 in for loop

1 vue (au cours des 30 derniers jours)
Andi Wang
Andi Wang le 4 Oct 2018
Commenté : Andi Wang le 4 Oct 2018
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

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Oct 2018
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 commentaire
Andi Wang
Andi Wang le 4 Oct 2018
the second one helps me a lot, cause I may want to separate in more than 10.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by