assign summary of a category to new variables

1 次查看(过去 30 天)
Hi everyone,
I have the following code:
A = categorical({'plane'; 'car'; 'train'; 'car'; 'plane'});
summary(A)
here is the output:
>> Untitled
car 2
plane 2
train 1
I want to assign the summary to a new variable. So I tried using b=summary(A), and got:
>> Untitled
Error using categorical/summary (line 98)
Too many output arguments.
Error in Untitled (line 2)
b=summary(A)
please help me fix this problem
Thanks
Peng

采纳的回答

Matt J
Matt J 2015-4-6
编辑:Matt J 2015-4-6
You can do this,
>> b=evalc('summary(A)')
b =
car 2
plane 2
train 1

更多回答(1 个)

Sean de Wolski
Sean de Wolski 2015-4-6
编辑:Sean de Wolski 2015-4-6
Or
c = categorical({'plane'; 'car'; 'train'; 'car'; 'plane'})
b = table(categories(c),countcats(c))

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by