필터 지우기
필터 지우기

Looping with unequal increment

조회 수: 4 (최근 30일)
Utsav
Utsav 2015년 1월 21일
댓글: John D'Errico 2015년 1월 21일
I have x= 5,15,25,30,45,60,65,70,75,90
other parameters (in the body of loop) depends on x values above
I have to run a loop
for i=min(x) : B :max(x)
Body
endfor
What shall be the B? How to go about it?
  댓글 수: 1
Stephen23
Stephen23 2015년 1월 21일
Note that you should not use i or j for your loop variable names, as these are the names of the inbuilt imaginary unit .

댓글을 달려면 로그인하십시오.

채택된 답변

Roger Stafford
Roger Stafford 2015년 1월 21일
편집: Roger Stafford 2015년 1월 21일
x = [5,15,25,30,45,60,65,70,75,90];
for i = 1:length(x)
% Get parameter values from x(i) and store them at i-th array positions
end
  댓글 수: 4
Roger Stafford
Roger Stafford 2015년 1월 21일
Good point, Stephen. I carelessly used 'i' here just because "i-th" is easier to pronounce than, say, "ix-th".
John D'Errico
John D'Errico 2015년 1월 21일
I'll admit, I like i as a loop variable. It is a throwback to my Fortran days, when i was the variable of choice for loops.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by