MATLAB: Finding max and min value for each number interval

MATLABMATLAB and Simulink Student Suiteminimum maximum

Hello,
I have stress strain data which has 5000 rows and I need to clean unnecesaay number. I only need max and min value for each number interval to perform interpolation. i dont know how to explain let me give you an example:
x=1.1,1.2, 1.3, 1.4, 1.9, 2.1, 2.2, 2.5 ,2.7, 2.9, 3.1, 3.4…… and i only need 1.9 and 2.1 2.9 and 3.0 to do interpolation. for the number 1 i need max and min value. for the number 2 i need min and max value and so on… Thank you so much in advance. I am sorry if I violete any rule. this is my first question here.

Best Answer

Using your example,
>> x=[1.1,1.2, 1.3, 1.4, 1.9, 2.1, 2.2, 2.5 ,2.7, 2.9, 3.1, 3.4];
>> xg=findgroups(fix(x))
xg =
1 1 1 1 1 2 2 2 2 2 3 3
>> intervalMin=splitapply(@min,x,xg)
intervalMin =
1.1000 2.1000 3.1000
>> intervalMax=splitapply(@max,x,xg)
intervalMax =
1.9000 2.9000 3.4000