フィルターのクリア

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by