Filter löschen
Filter löschen

Indexing in for loop

1 Ansicht (letzte 30 Tage)
Prathamesh Walunj
Prathamesh Walunj am 7 Jun. 2021
Beantwortet: Shivani Dixit am 7 Jun. 2021
How to use indexing in a for loop?

Akzeptierte Antwort

Shivani Dixit
Shivani Dixit am 7 Jun. 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
You can leverage the mathwork documentation for more information on indexing in loops in matlab :

Weitere Antworten (1)

KSSV am 7 Jun. 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)


Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by