How can I slove the maxtric

3 ビュー (過去 30 日間)
Tran David
Tran David 2021 年 2 月 17 日
コメント済み: Tran David 2021 年 2 月 17 日
HI all, I'm not understanding how the code computes a C matrix . pls help me
i am a newbie...
A=[2;0;0;0;1]
B=[5;1;4;1]
C=A(B,1)
---> C=[ 1;2;0;2]

回答 (2 件)

John D'Errico
John D'Errico 2021 年 2 月 17 日
You want to slove a matrix? Sorry. Valentines day was 3 days ago. Too late for s"love".
A is a column vector, composed of the elements [2 0 0 0 1].
B is a vector, used to index into the matrix (or vector) A.
What is the 5th element of A? Hint: Matlab uses a 1 based index system. So the 5th element of A is 1. Likewise, the 1st element of A is 1, etc.
  1 件のコメント
Tran David
Tran David 2021 年 2 月 17 日
<3 thanks for your help.

サインインしてコメントする。


David Hill
David Hill 2021 年 2 月 17 日
C is produced from indexing the values of B into A.
A(5)=1;A(1)=2;A(4)=0;A(1)=2;
C=A(B);%don't need the 1
  1 件のコメント
Tran David
Tran David 2021 年 2 月 17 日
I’m extremely grateful for you

サインインしてコメントする。

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by