Sorting maximum value array by same date and time

1 view (last 30 days)
I have an array of very large size 708273*3,the first and second column representing time and date respectively. Each time and date have many values. I need to find out maximum value from that. I have no idea with how to short those value from excel. Sample data file name "test1".
Any help will be highly appreciated.
With best regards,
Somnath

Answers (1)

Ameer Hamza
Ameer Hamza on 28 May 2020
Try this
T = readtable('test1.xlsx');
grps = findgroups(T.Time, T.Date);
max_vals = splitapply(@max, T.Value, grps);
T.MaximumValue = max_vals(grps);
writetable(T(:,'MaximumValue'), 'test1.xlsx', 'Range', 'D1')
  24 Comments
Ameer Hamza
Ameer Hamza on 28 May 2020
Yes, it seems possible, but the first column of the excel file is in some custom format, which is not recognized by MATLAB. You may first need to change the data type of the first column in Excel and then follow the code in my comment to only save each maximum value once.
SOMNATH MAHATO
SOMNATH MAHATO on 28 May 2020
can you suggest, how i would change my data type?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!