MATLAB: How to select a data set from columns having using criteria

how to select a data set from columns having using criteria?MATLAB

I have 5 columns in the file mycolumns. They all have the same dimension. I would want to reduce the number of rows of all the columns by same amount by selecting the row that first meet the condition where the elements of columns "acc<10" and "C<20". I am interested in the first row meeting the criteria to the end of rows of each column. Again I would want to know the time the first row met the criteria and then subtract for the initial time,thus, time(1,1) to obtain the number of minutes it took for the criteria to be met. Thanks for you support.

Best Answer

EDIT — Edited to produce only the data from the time criteria are met until the end of the data.
See if this does what you want:
D = load('mycolumns.mat');
Ix1 = find((D.acc < 10) & (D.C < 20));
t0 = D.time(Ix1(1)); % First Time Criteria Met
new_time = D.time(Ix1:end)-t0; % Time From ‘t0’ To End
new_acc = D.acc(Ix1:end); % Corresponding ‘acc’
new_C = D.C(Ix1:end); % Corresponding ‘C’
figure(1)
plot(new_time,new_acc, new_time,new_C)
grid
legend('acc', 'C', 'Location','NW')
xlabel('time')