How do i count unique elements in two table columns?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ahmed obaid
am 9 Jun. 2017
Kommentiert: ahmed obaid
am 9 Jun. 2017
Dear all;
for the following table:which include student name, class and school name ..
std_name class School
A1 1 Art
A2 1 Art
A3 1 Muc
A4 2 muc
A5 3 Art
A6 2 fun
A7 3 fun
A8 4 Muc
...
i need to count : - how many student in every class, then write new table includes the following result as example: class number and how many student in every class, then names of schools... as shown below:
class No. of std School
1 50 Art, Muc
2 30 muc, fun
3 10 Art, fun
4 100 muc
etc..
-
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 9 Jun. 2017
Bearbeitet: Andrei Bobrov
am 9 Jun. 2017
A = readtable('A.csv');
A.Properties.VariableNames = {'std_name','class','School'};
[g,ii] = findgroups(A.class);
out = table(ii,accumarray(g,1),splitapply(@(x){strjoin(unique(x),',')},A.School,g),...
'var',{'class','No_of_std','School' });
5 Kommentare
Guillaume
am 9 Jun. 2017
Bearbeitet: Guillaume
am 9 Jun. 2017
You download R2015b like you download any other releases, directly from the mathworks site:
To see what's new in R2015b: https://uk.mathworks.com/help/releases/R2015b/matlab/release-notes.html#R2015b
But if you're going to upgrade, you'd be better off moving to the latest version: 2017a
Siehe auch
Kategorien
Mehr zu MATLAB Report Generator 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!