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 CenterFile Exchange에서 Loops 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