Indexing in for loop

7 ビュー (過去 30 日間)
Prathamesh Walunj
Prathamesh Walunj 2021 年 6 月 7 日
回答済み: Shivani Dixit 2021 年 6 月 7 日
How to use indexing in a for loop?

採用された回答

Shivani Dixit
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 :

その他の回答 (1 件)

KSSV
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

カテゴリ

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