MATLAB: How to find minimum value within specific segments of a matrix using Vectorization

minimum valuevectorization

I have the following matrix:
A=[1 0.1; 1 0.15; 1 0.35; 1 0.22; 2 0.45; 2 0.69; 2 0.33;...600 0.27; 600 0.34; 600 0.22];
Here first column (numbers 1, 2…600) represents time and second column (numbers 0.1, 0.15,0.35 etc.) represents fuel consumption. I need to find the value of minimum fuel consumption for each time period( for time=1s there will be a single min value and so on for each time) and store it in another array. This is just a example and actual number of data points are very large and using of for loops is time consuming. How can I solve this problem using Vectorization method or without using any loops? Thanks in advance!

Best Answer

A = [1 0.1;
1 0.15;
1 0.35;
1 0.22;
2 0.45;
2 0.69;
2 0.33;
600 0.27;
600 0.34;
600 0.22];
[uniqueA,~,jj] = unique(A(:,1));
uniqueMin = accumarray(jj,A(:,2),[],@min);
uniqueAandMin = [uniqueA,uniqueMin];