Indexing in for loop
조회 수: 1 (최근 30일)
이전 댓글 표시
How to use indexing in a for loop?
댓글 수: 0
채택된 답변
Shivani Dixit
2021년 6월 7일
Assuming you are using MATLAB, the indexing begins from 1. An example for for loop is explained below:
arr = [1 2 3 4 ] % assuming an example array
for i=1:length(arr)
x=arr(i) % we access elements using paranthesis
end
You can leverage the mathwork documentation for more information on indexing in loops in matlab :
댓글 수: 0
추가 답변 (1개)
KSSV
2021년 6월 7일
You can read the documentation instead asking such simple questions.
A = rand(10) ;
[m,n] = size(A) ;
for i = 1:m
for i = 1:n
a = A(i,j)
end
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!