Array Indexing, Array within an Array

5 ビュー (過去 30 日間)
Christopher Wible
Christopher Wible 2019 年 6 月 19 日
回答済み: Matt J 2019 年 6 月 19 日
I need help understanding how this code works.
Consider the variables B = [1 5 8] and D = [1; 1; 1]. When I write the code B(D,:) I am getting the output of [1 5 8; 1 5 8; 1 5 8] and I am not sure why.
Please be thorough in your explination.
Thanks for the help.

採用された回答

Matt J
Matt J 2019 年 6 月 19 日
Because, by definition,
B(D,:) = [ B(D(1),:) ; B(D(2),:) ; B(D(3),:) ]
= [ B(1,:) ; B(1,:) ; B(1,:) ]
= [1 5 8; 1 5 8; 1 5 8]

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by