AVG, occurence, vlook up, groups
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Marek Drliciak
am 10 Nov. 2022
Verschoben: Image Analyst
am 21 Nov. 2022
Hello,
I would like to ask for help in determining the average of values in specific groups of data in a database. I processed the issue in excel in the attachment. This is a preview.
Thank you
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 10 Nov. 2022
Try this:
data = readmatrix('Problem description.xlsx', 'Range', 'b3:c31')
averages = grpstats(data(:, 2), data(:, 1), "mean")
counts = histcounts(data(:, 1))
3 Kommentare
Image Analyst
am 11 Nov. 2022
Then you need to identify each group in column 1 with a separate ID number which you can do with bwlabel in the Image Processing Toolbox.
data = readmatrix('Problem description.xlsx', 'Range', 'b3:c31')
% Identify separate groups:
[groupIDs, numGroups] = bwlabel(data(:, 1))
averages = grpstats(data(:, 2), groupIDs, "mean")
counts = histcounts(groupIDs)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!