How can I concatenate a "datetime" column to a matrix of numbers?
Show older comments
I have imported a table from an external file via textscan. For example:
A = rawCellColumns2(:, 1);
B = cell2mat(rawNumericColumns2(:, 1));
C = cell2mat(rawNumericColumns2(:, 2));
D = cell2mat(rawNumericColumns2(:, 3));
E = cell2mat(rawNumericColumns2(:, 4));
A is "datetime" in this form:
2019-07-10 22:00:00
B, C, D, and E are all numbers.
I now want to make a new table (Z) by concatenating A - E. However, I get the error below because of the datetime column (I have no problem concatenating the columns of numbers by doing B(:), C(:), D(:), E(:)):
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
People have addressed this problem here at Matlab Answers, but as a bit of a newbie, I would be very grateful if someone could please provide a newbie-level explanation. I am using 2016a. Thank you very much for any advice.
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and 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!