フィルターのクリア

for loop function help

1 回表示 (過去 30 日間)
Vc27
Vc27 2022 年 11 月 18 日
コメント済み: Vc27 2022 年 11 月 18 日
i don't have a specific example but could someone explain the for loop function - i find it very confusing.
if someone could explain for i, else, elseif please

採用された回答

Image Analyst
Image Analyst 2022 年 11 月 18 日
help for
FOR Repeat statements a specific number of times. The general form of a FOR statement is: FOR variable = expr, statement, ..., statement END The columns of the expression are stored one at a time in the variable and then the following statements, up to the END, are executed. The expression is often of the form X:Y, in which case its columns are simply scalars. Some examples (assume N has already been assigned a value). for R = 1:N for C = 1:N A(R,C) = 1/(R+C-1); end end Step S with increments of -0.1 for S = 1.0: -0.1: 0.0, do_some_task(S), end Set E to the unit N-vectors for E = eye(N), do_some_task(E), end Long loops are more memory efficient when the colon expression appears in the FOR statement since the index vector is never created. The BREAK statement can be used to terminate the loop prematurely. See also PARFOR, IF, WHILE, SWITCH, BREAK, CONTINUE, END, COLON. Documentation for for doc for Other uses of for matlab/for
help if
IF Conditionally execute statements. The general form of the IF statement is IF expression statements ELSEIF expression statements ELSE statements END The statements are executed if the real part of the expression has all non-zero elements. The ELSE and ELSEIF parts are optional. Zero or more ELSEIF parts can be used as well as nested IF's. The expression is usually of the form expr rop expr where rop is ==, <, >, <=, >=, or ~=. Example if I == J A(I,J) = 2; elseif abs(I-J) == 1 A(I,J) = -1; else A(I,J) = 0; end See also RELOP, ELSE, ELSEIF, END, FOR, WHILE, SWITCH. Documentation for if doc if
  1 件のコメント
Vc27
Vc27 2022 年 11 月 18 日
Thank you

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

その他の回答 (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