フィルターのクリア

combine doubles and categorical

20 ビュー (過去 30 日間)
Rogier Busscher
Rogier Busscher 2017 年 5 月 25 日
編集済み: Abel Babu 2017 年 5 月 30 日
I have three doubles (11318560x1 double) and three categoricals of the same length. How do I combine these into a matrix (of 11318560x6)?
  1 件のコメント
Rogier Busscher
Rogier Busscher 2017 年 5 月 25 日
Just to be clear, I tried [A B C X Y Z], but the error I get is:
Error using categorical/cat (line 43) Can not concatenate a double array and a categorical array.
Error in categorical/horzcat (line 22) a = cat(2,varargin{:});

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

採用された回答

Abel Babu
Abel Babu 2017 年 5 月 30 日
編集済み: Abel Babu 2017 年 5 月 30 日
Hi,
The data structure that fits your use case is the MATLAB tables, more about the same can be read here: https://in.mathworks.com/help/matlab/ref/table.html
To give a sample code:
double1 = [1;2;3];
double2 = [3;4;5];
double3 = [5;6;7];
catData1 = {'tag1';'tag2';'tag3'};
catData2 = {'tag3';'tag4';'tag5'};
catData3 = {'tag5';'tag6';'tag7'};
rownames = {'double1';'double2';'double3';'categorical1';...
'categorical2';'categorical3'};
T = table(double1,double2,double3,categorical(catData1),...
categorical(catData2),categorical(catData3),'VariableNames',rownames);
Do refer the 'categorical' function used in the code in this link: https://in.mathworks.com/help/matlab/ref/categorical.html
Abel

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by