MATLAB: Check a column, if a condition is met use those value

if loop

I have excel file containing cyclic data of 25 by 1000. Let say column 3 represent cycle. i was able to plot the data for all cycle. The problem is I am not sure how to plot for specific cycle. sample date could be: A=[1,2,1,4,5;6,7,1,9,10;11,12,1,14,15;16,17,2,19,20;21,22,2,24,25;26,27,2,29,30]
My question is how to chose date from other column when column 3 is specific cycle.(it could be 1, 2, 3 or 1 to 5 or 10 11 13).
Any help would ne much appricated

Best Answer

  • A=[1,2,1,4,5;6,7,1,9,10;11,12,1,14,15;16,17,2,19,20;21,22,2,24,25;26,27,2,29,30] ;
    %%pick cycle 1
    c1 = A(A(:,3)==1,:)
    %%pick cycle 2
    c2 = A(A(:,3)==2,:)