MATLAB Answers

Sorting maximum value array by same date and time

3 views (last 30 days)
SOMNATH MAHATO
SOMNATH MAHATO on 28 May 2020
Edited: madhan ravi on 28 May 2020
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.