Error when combine tables vertically under some circumstances
Mostra commenti meno recenti
I have two sets of data, up_data and upt_data. They have the same variable names. But when I try to use [up_data; upt_data] to combine them, error pops out as following:
An error occurred when concatenating the table variable 'posture' using VERTCAT.
Caused by:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Here is a test to show that the variable names are the same.

However, when I write them into csv files and then read them back as follows:
writetable(up_data, 'up_data.csv');
writetable(upt_data, 'upt_data.csv');
up_data = readtable('up_data.csv');
upt_data = readtable('upt_data.csv');
upright_alldata = [up_data ; upt_data];
It works perfectly well. I wonder what went wrong. I attached the csv files as well for your references.
5 Commenti
Scott MacKenzie
il 8 Giu 2021
I didn't get an error using your concatenation code:
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/645930/up_data.csv');
T2 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/645935/upt_data.csv');
T3 = [T1; T2];

Jinyang Du
il 8 Giu 2021
Cris LaPierre
il 8 Giu 2021
Modificato: Cris LaPierre
il 8 Giu 2021
It would appear the data you need to share is the original up_data and upt_data variables, not the csv files. You can save them to a mat file and attach them to your post.
In the meantime, what is the size of posture in your tables?
sUP = size(up_data.posture)
sUPT = size(upt_data.posture)
Scott MacKenzie
il 8 Giu 2021
Modificato: Scott MacKenzie
il 8 Giu 2021
I suggest you provide an example minimal set of MATLAB statements that generates the error you are seeing. Furthermore, to make things easier for someone trying to help you, it's best to do this by embedding the code directly in your question or comment
Jinyang Du
il 8 Giu 2021
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Tables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!