how to divide excel files in matlab into uneven groups
Show older comments
i have excel file with 3000 row and 1 column. once i import it using xlsread (data),i want to calculate the average values based on the range in i, i= 1,120,500, 1500, 2300,3000. That means the first average value contains the data from row 3 to row 120 and the second from 121 to 500 and so on. so at last the average values can be a column vecor with 5 rows .Could you please help. Thanks
Accepted Answer
More Answers (1)
Star Strider
on 7 Jul 2015
You can do it without loops, using cell arrays:
V = randi(99, 3000, 1); % Create Data
Partitions = diff([0 120 500 1500 2300 3000]); % Define Vector Partitions
C = mat2cell(V, Partitions, 1); % Create Cell Arrays
Result = cellfun(@mean, C); % Take Means
The ‘Result’ assignment is the output, containing the means of the partitioned vector.
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!