What does this function do in matlab?

1 Ansicht (letzte 30 Tage)
Neo
Neo am 2 Feb. 2016
Kommentiert: Neo am 3 Feb. 2016
Say I have D = D(somevector);
and A = A(:,somevector);
Does the former make this a column? What is it doing if not? Does the latter make a matrix A in some arrangement?
Please provide a link to where I can read more about this. I have been web surfing for too long.
Cheers, Neo!

Akzeptierte Antwort

James Tursa
James Tursa am 2 Feb. 2016
Bearbeitet: James Tursa am 2 Feb. 2016
See the link on indexing:
In particular, if you supply only one subscript as in your first example, then MATLAB will use what is known as "Linear Indexing" in the link, and give you a column vector as a result with the elements being composed of the linear indexed elements you specified with somevector.
In your second example, you supplied two indexes. The result will be a sub-matrix composed of all the rows (via the : supplied for the first index), and the columns supplied by your somevector.
  3 Kommentare
Neo
Neo am 3 Feb. 2016
Thanks Walter. I would've accepted your answer but you left it as a comment!
-Cheers Neo
Neo
Neo am 3 Feb. 2016
Thanks James!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by