Replace categorical value with numeric values

I want to replace my categorical data with numeric representation in my 4th column. They values are randomly dispersed in the column. The values are white and black. I would like to replace all "white" values with the number 1 and black with the number 0. Then I would like to export the file as ".xls" Can anyone help me? Thank you!

回答 (1 件)

dpb
dpb 2019 年 6 月 20 日

0 投票

If categorical variable is c, then
d=double(c)-1;
presuming didn't define them except by default which will be in alphanumeric order beginning with one (1).

カテゴリ

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

質問済み:

2019 年 6 月 20 日

回答済み:

dpb
2019 年 6 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by