MATLAB: Converting a the result vector from logical indexing into a matrix possible or unnescesary

logical indexingmatrixrow extractionvector conversion

Hello everyone,
I need to extract rows of a matrix with a certain value in one column. At the moment I am using logical indexing i this way:
c=A(:,2)==3; T=A([c,c,c,c]);
The problem I have is that T is a vector, with the columns added end to end, but I need it as a matrix.
Does Matlab provide an easy way to convert such a vector to a matrix or is there another easy way to extract the rows into a matrix?
Thank you everybody.

Best Answer

  • T = A(A(:,2) == 3,:);