# how to pick a colum vector from a matrix

Discussion in 'MATLAB' started by marc valente, Dec 8, 2006.

1. ### marc valenteGuest

I was just woundering if it is posible to pick out a colum vector
from a matirx. That is if I just wanted the jth colum in an nxn
matrix is there a way to assing it to a variable?

marc valente, Dec 8, 2006

2. ### mamdouhGuest

Hi
Please see the following example it it helps

%data
A=[1 2 3; 4 5 6; 7 8 9];
%results
column1=A ,1);
column2=A ,2);
column3=A ,3);
Mamdouh

regards

mamdouh, Dec 8, 2006

3. ### bahhhhhhhhhhhGuest

additionally, if you want just rows you could say (r, where r is
the row you desire. if you want several rows or columns (a submatrix)
try (1:3, which would be the first three rows or ,2:5) which
would be columns 2-5. good luck

bahhhhhhhhhhh, Dec 8, 2006
4. ### usGuest

marc valente:
<SNIP cotton-picking - column-picking...

one of the many solutions

% the matrix
m=magic(7)
% the picking index/indices
ix=[1:3,5,7];
% the col submat
mc=m ,ix)
% the row submat
mr=m(ix, us

us, Dec 8, 2006