How do I insert a 1x1 cell array consisting of one vector into a table?
Show older comments
I have the following code block to set up my problem:
test_table = table('Size',[2,1],'VariableTypes',"cell",'VariableNames',["Coordinates"]);
test_array = [2,2,2,2,2]; % single row vector
% Try assigning test_array to a slot in the table
test_table(1,1) = {test_array};
Notice that the code cell above throws the following error "Conversion to cell from double is not possible." However, if I change the value of test_array to a matrix, and try the assignment again...
test_array = [2,2,2,2,2;3,3,3,3,3]; % matrix
% Try assigning test_array to a slot in the table
test_table(1,1) = {test_array}
...things go off without a problem. First question is, why does matlab treat the assignment differently between a vector and a matrix? Second question is, how do I make the assignment in the first code block (assigning a 1x1 cell array consisting of a single row vector into a slot in a table) work?
Accepted Answer
More Answers (1)
coordinates = [2,2,2,2,2]'; % single row vector
T = table(coordinates)
Categories
Find more on Cell Arrays 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!