简体   繁体   中英

Set vector equal to row of matrix matlab

I'm new to matlab and would like to create a new vector equal to a row of an nxn matrix that I already have. I know how to do it with loops but is there a command? Something like

vector1=matrix1(row5)

Thanks!

Yep this is easy, the syntax is:

row5Vector = matrix1(5,:);

Also to grab a column you could:

col5Vector = matrix1(:,5);

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