how can i use averaging from excel file

I have two columns F and M in Excel.In F column i have repetetive numbers and in M column i have different numbers.For each Group of numbers in F i want a average in M Column. for example :F= 111 22 33 444 and M= abc de fh ijk. at the end i must have: F=1 2 3 4, M=(a+b+c)/3 (d+e)/2 (f+h)/2 (i+j+k)/3

 Accepted Answer

Jan
Jan on 18 May 2017
Edited: Jan on 18 May 2017
Does this problem concern Excel? Are you able to import the data already to a matrix? If not, please ask for importing Excel files explicitely.
F = [1 1 1 2 2 3 3 4 4 4];
M = rand(size(F));
[~, FF] = findgroups(F.');
MM = splitapply(@mean, M.', F.')

2 Comments

Hi, tnx for your answer.I describe it again
@mehdi moudi: This exactly what the suggested code should do. Is your problem solved?

Sign in to comment.

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Asked:

on 18 May 2017

Commented:

Jan
on 19 May 2017

Community Treasure Hunt

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

Start Hunting!