MATLAB: Selecting particular data range from table/ columns

MATLABsearch

Hi there,
I am very new to Matlab and haven't been able to find the following solution.
I have two columns within a table of 1537090 x 2. Within the second column I want to extract numbers that fall within a range of 15 to 50.
Any numbers that are found in that range in column 2 I would like the corresponding row from Column 1 to also be pulled out.
The result will be another two column table but have all values within 15 to 50 from Column 2 and the corresponding rows from Column 1.
Thanks very much in advance and really appreciate any help.

Best Answer

Try this:
T1 = table(rand(100,1), randi(75,100,1)); % Original Table
L = table2array(varfun(@(x)((x>=15) & (x<=50)), T1(:,2))); % Logical Vector
T2 = T1(L,:); % Edited Table
.