简体   繁体   中英

how to select the first few elements of product of two matrices and store it to another matrix in matlab

A----is 3*1 matrix B----is 4*4 matrix C----is 3*1 matrix the formuale is [A;1]=B*[C;1] from this A needs to be extracted.That is add a row of 1 to matrix C. Then extract the first 3 elements of B*C and store it to matrix A. what i tried was A = B*[C;1]([0 1 2]) ------did not work. cannot use any other matrices other than A,B and C.

Indexing starts with 1 in matlab, the first three elements are [1,2,3] or [1:3] . You also need to split this into two lines:

t = B*[C;1]
A=t(1:3)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM