MATLAB: How to get value in a column or row

columnget value in a column or row

Hi member, I have a matrix Ex a=[1 2 3 5 6 8], and I only want to take b= a(1), a(2) and a(4) : 1,2,5 in stead of the whole column. Can you instruct me to do it. Thank you.

Best Answer

a=[1 2 3 5 6 8] ;
idx = [1 2 4] ;
b = a(idx) ;