convert double array to categorical

Hi there!
I want to convert double array to categorical.
Double array is b:
>>a = unique(b)
>> a =
0
0.0100
0.0200
0.0300
0.0400
0.0500
0.0500 ( I don't know why there are two 0.0500)
.......
0.3400
0.4600
0.6600
1.4300
>> whos b
>> Name Size Bytes Class Attributes
b 793505x1 6348040 double
>> categorical(b)
>> Error using categorical (line 434)
Unable to create default category names. Specify
category names using the CATEGORYNAMES input argument.
I got this error while converting data type and I could not figure out where the question is. Hope you guys can help me.
Thank you very much in advance.
Yinghai

1 件のコメント

aybike pirol elmas
aybike pirol elmas 2020 年 6 月 2 日
Hello,
Did you find the solution for your error??

サインインしてコメントする。

回答 (1 件)

Steven Lord
Steven Lord 2020 年 6 月 2 日

1 投票

Consider using discretize.
x = rand(10, 1);
c = discretize(x, 0:0.25:1, 'categorical');
t = table(x, c)

カテゴリ

ヘルプ センター および File ExchangeCategorical Arrays についてさらに検索

質問済み:

2019 年 3 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by