MATLAB: How to select certain columns of a matrix only when the values in certain rows showing the the double of the value in a particular row of a column

bigger ascolumns selection

Hi everybody!
I have a Matrix with 5 rows and 2300 columns M(5,2300).
0.2 0.3 0.4 2 ...
3 0.5 1.9 2.5 ...
2 0.7 0.2 3 ...
1 1 1 1 ...
0.5 0.1 1.5 3.1 ...
looks like above. The numbers you see are ratios because all the values of a particular column were divided by the value in the 4th row (which is now 1). I intend to just keep the columns for future analysis when at least one value of the other rows in a column (row1:3 and row5 values) are >=2, meaning that they should be at least the double of the value in the 4th row. As an output from the columns above it should give me an index like [1,0,0,1].
Could you probably suggest a nice solution? I'm thankful for every help.

Best Answer

Let A be your 5*n matrix.
% GEt ratio
R = A(1:3,:)./A(5,:) ;
idx = R>=2 ; % get indices where ratio is >= 2