alternative to groupcounts function

I have made a script which I used groupcounts() function.
The pc where the script is running is previous to 2019. So that function is not recognized. I have tried to copy the function in the path but I get this error
{Undefined variable "matlab" or class "matlab.internal.math.parseGroupVars".
Error in groupcounts (line 105)
[groupingData,groupVars] =
matlab.internal.math.parseGroupVars(T,tableFlag,'groupcounts');
is there other function that provide the same outputs but work in previous versions than 2019?

 Accepted Answer

I found this way. I hope someone can provide nicer way.
Original:
[xx,yy] = groupcounts(temp);
Alternative:
[xx0,yy] = findgroups(temp);
[xx,~] = histc(xx0,unique(xx0));

More Answers (1)

doc groupsummary
doc splitapply

1 Comment

I am using this from, with temp is a cell array of strings. I need both oputputs. The functions you mentioned dont workfor my case
[xx,yy] = groupcounts(temp);

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 8 Sep 2020

Answered:

on 10 Sep 2020

Community Treasure Hunt

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

Start Hunting!