adding column ( cell) to matrix
조회 수: 29 (최근 30일)
이전 댓글 표시
I created a vector cell that I want to add it to existing matrix
I'm getting below error
Inconsistent concatenation dimensions because a 24-by-3 'double' array was converted
to a 1-by-1 'cell' array. Consider creating arrays of the same type before concatenating.
here is how I created the cell
Facies=cell(length(data),1);
Facies(1:2,1)={'cat'};
Facies(3:5,1)={'dog'};
Facies(6:24,1)={'mouse'};
댓글 수: 0
답변 (3개)
Sulaymon Eshkabilov
2021년 11월 9일
WHat you are trying to do is to augment all variables into one array, correct? In this case, table array might be a good one, e.g.:
x = (1:5).'; % Vector
F1 = categorical({'A'; 'B'; 'C'; 'D'; 'E'}); % Cell Categorical Array
F2 = categorical({'W'; 'U'; 'X'; 'Y'; 'Z'}); % Cell Categorical Array
T = array2table(F1);
T.F2 = F2;
T.x = x
Sulaymon Eshkabilov
2021년 11월 9일
x = (1:5).'; % Vector
F1 = categorical({'A'; 'B'; 'C'; 'D'; 'E'}); % Cell Categorical Array
F2 = categorical({'W'; 'U'; 'X'; 'Y'; 'Z'}); % Cell Categorical Array
T = array2table(F1);
T.F2 = F2;
T.x = x;
Mean_x = mean(T.x)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!