MATLAB: Selecting specific data from raw data based on conditions

arithmeticequationsif statementlogical conditions

I have a huge set of data, I want to apply these conditions on the raw set of data so that the data which meets the criteria specified in the conditional equations only gets selected. Whats the best way to do that in matlab?

Best Answer

Using "logical addressing" is generally an efficient technique. I use a helper function I call iswithin to remove the complexity of the logical expressions from the higher level code but it's just "syntactic sugar" from an implementation standpoint...
>> type iswithin
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
>>
Use would be something like
idxGd=iswithin(Gd,0,1.1*G);
idxG =iswithin(G,0,1.2*Goh);
and the overall a combination with the above for the actual data structure used as Walter notes. It's likely a single array and column indexing could be very effective here depending on the actual data availability, spacing, etc., etc., ...