티스토리 뷰

1. Syntax

  • for 시작값:증감값:종료값
  •      구문
  • end
total = 0;

for i = 1:2:10 
    total = total + i;
end

disp(total);

☞ 증감값을 명시하지 않은 경우에는 1이 default


2. Execute  Statements for Specified Values

  • 각 배열의 원소마다 실행
for v = [1 5 8 17]
   disp(v)
end

3. Repeat Statements for Each Matrix Columns

  • 행렬의 경우는 각 열마다 실행
for I = eye(4,3)
    disp('Current unit vector:')
    disp(I)
end

Reference: https://www.mathworks.com/help/matlab/ref/for.html

'Computer Language > Matlab' 카테고리의 다른 글

if 문(if statements)  (0) 2018.08.02
while 문(while loop)  (0) 2018.08.01
함수(Function)  (0) 2018.07.28
형태 변형(Reshape and Rearrange)  (0) 2018.07.27
행렬과 배열(Matrices and Arrays)  (0) 2018.07.25
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/12   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함