Iterating over Columns/Rows (no index)

Standard way to iterate over matrix columns or rows is to use an incrementing iterator and index the matrix from there.
Are there alternative ways to do this?
Similar to iterating over vector values, like this:
for value = some_vector
...
end

Antworten (1)

Yongjian Feng
Yongjian Feng am 21 Nov. 2021
Bearbeitet: Yongjian Feng am 21 Nov. 2021

0 Stimmen

If the array is a row vector, then it works
a = [1 2 3]
for i = a
disp(i)
end

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2021b

Tags

Gefragt:

am 21 Nov. 2021

Bearbeitet:

am 21 Nov. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by