MATLAB: How to filter a certain range of values in a column vector of thousand rows

filter a certain range of values

I want to find a range of values in a column vector of a minimum value of 20% and a maximum value of 90%. The column has 2000 rows. suppose i want to filter values between a range of 70% to 80%. sample code for i = 1:length(PP) if (70% <= PP(i) <= 80%) filtered_PP(i) = PP(i) end end I later separate it and still i'm not getting the correct the answer
for i = 1:length(PP) if (70% <= PP(i) && 80% >= PP(i)) filtered_PP(i) = PP(i) end end

Best Answer

PP = (0:100)';
filtered_PP_Idx = find((PP>=73 & PP<=80));
filtered_PP = PP(PP>=70 & PP<=80);
Related Question