adding column ( cell) to matrix
23 views (last 30 days)
Show older comments
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 Comments
Answers (3)
Sulaymon Eshkabilov
on 9 Nov 2021
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
on 9 Nov 2021
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)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!