필터 지우기
필터 지우기

To convert categorical to double

조회 수: 129 (최근 30일)
Anjan
Anjan 2018년 3월 23일
댓글: Leonardo 2024년 6월 26일 3:14
Convert categorical '12' to double/numeric 12
%For example
Data=[2 36; 56 23]; %If i execute this data it will be in double format
To_categorical=categorical(Data); % then i am converting to categorical format
To_double= ???? % If i need to convert "TO_categorical" back to double
  댓글 수: 2
Ravindu Kodagoda Pathiranage
Ravindu Kodagoda Pathiranage 2022년 10월 19일
To_double = double(string(To_categorical));
Leonardo
Leonardo 2024년 6월 26일 3:14
Thanks!

댓글을 달려면 로그인하십시오.

답변 (3개)

cater re
cater re 2019년 11월 20일
편집: cater re 2019년 11월 20일
If you have source. you can do it with below.
data = [2 7 3 50 5 6 60]
catdata = categorical(data)
catidx = double(catdata)
sdata = sort(data)
converted = sdata(catidx)
If there is no source, how to convert it?
catdata = categorical([2 7 3 50 5 6 60])
converted = str2num(char(catdata))'
If useful, thumb up!

KSSV
KSSV 2018년 3월 23일
Read about double
Data=[2 36; 56 23]; %If i execute this data it will be in double format
To_categorical=categorical(Data)
idx = double(To_categorical) ;
Data(idx)
  댓글 수: 1
Anjan
Anjan 2018년 3월 23일
This works only when there is still "Data=[2 36; 56 23];" in the workspace.
Please check the file with this attachment. I just want to convert that categorical table to double format.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2019년 11월 20일
catdata = categorical([2 7 3 50 5 6 60]);
catnames = categories(catdata);
converted = str2double(catnames(catdata)).';

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by