Indexing in for loop

7 visualizzazioni (ultimi 30 giorni)
Prathamesh Walunj
Prathamesh Walunj il 7 Giu 2021
Risposto: Shivani Dixit il 7 Giu 2021
How to use indexing in a for loop?

Risposta accettata

Shivani Dixit
Shivani Dixit il 7 Giu 2021
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 :

Più risposte (1)

KSSV
KSSV il 7 Giu 2021
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

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by