What does this function do in matlab?

1 次查看(过去 30 天)
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!

采纳的回答

James Tursa
James Tursa 2016-2-2
编辑:James Tursa 2016-2-2
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 个评论
Neo
Neo 2016-2-3
Thanks Walter. I would've accepted your answer but you left it as a comment!
-Cheers Neo

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by