Could anyone help me out in finding frequency of data using excel file and later finding the row having maximum frequency?

2 views (last 30 days)
From the range column of excel file attatched, I need to sum up each row ( columns b to h) and store the sum value in a matrix.
After I get a matrix of sum values of each row. Further the max value of that matrix is needed to be found and corresponding range to which it belongs. Could anyone help me out how I can achieve this using matlab code. The excel file is attatched.

Accepted Answer

Kevin Holly
Kevin Holly on 6 Nov 2022
t = readtable('frequency.xlsx')
t = 23×8 table
Range b c d e f g h _____________ __ __ _ _ _ _ _ {'125 - 135'} 6 6 0 0 0 0 0 {'135 - 145'} 9 2 0 1 0 0 0 {'145 - 155'} 8 6 1 1 0 0 0 {'155 - 165'} 11 1 2 0 0 0 0 {'165 - 175'} 5 3 0 0 0 0 0 {'175 - 185'} 15 4 2 2 1 0 0 {'185 - 195'} 25 8 2 0 0 0 0 {'195 - 205'} 25 15 0 0 0 1 1 {'205 - 215'} 35 27 6 1 1 0 0 {'215 - 225'} 23 21 3 0 0 0 0 {'225 - 235'} 25 16 4 0 0 0 0 {'235 - 245'} 13 8 4 0 0 0 0 {'245 - 255'} 13 16 4 0 0 0 0 {'255 - 265'} 8 13 9 1 0 0 0 {'265 - 275'} 7 6 2 3 1 0 0 {'275 - 285'} 1 6 5 3 0 0 0
t.Sum = sum(table2array(t(:,2:end)),2)
t = 23×9 table
Range b c d e f g h Sum _____________ __ __ _ _ _ _ _ ___ {'125 - 135'} 6 6 0 0 0 0 0 12 {'135 - 145'} 9 2 0 1 0 0 0 12 {'145 - 155'} 8 6 1 1 0 0 0 16 {'155 - 165'} 11 1 2 0 0 0 0 14 {'165 - 175'} 5 3 0 0 0 0 0 8 {'175 - 185'} 15 4 2 2 1 0 0 24 {'185 - 195'} 25 8 2 0 0 0 0 35 {'195 - 205'} 25 15 0 0 0 1 1 42 {'205 - 215'} 35 27 6 1 1 0 0 70 {'215 - 225'} 23 21 3 0 0 0 0 47 {'225 - 235'} 25 16 4 0 0 0 0 45 {'235 - 245'} 13 8 4 0 0 0 0 25 {'245 - 255'} 13 16 4 0 0 0 0 33 {'255 - 265'} 8 13 9 1 0 0 0 31 {'265 - 275'} 7 6 2 3 1 0 0 19 {'275 - 285'} 1 6 5 3 0 0 0 15
[maxvalue, Index] = max(t.Sum)
maxvalue = 70
Index = 9
t(Index,[1 end])
ans = 1×2 table
Range Sum _____________ ___ {'205 - 215'} 70

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!