如何合并具有不同行数的表?

How can I merge tables with different numbers of rows?

我目前正尝试在 MATLAB 中创建信号过程图。为了做到这一点,我有 3 个表格,我想绘制不同的信号,这些信号需要合并才能绘制在同一个图表上(但分开以便分别查看信号)。

到目前为止我已经尝试过:

% The variables below are examples of the tables that contain 
% the variables I would like to plot.

s1 = table(data1.Time, data1.Var1); % This is a 8067x51 table
s2 = table(data2.Time, data2.Var2); % This is a 2016x51 table
s3 = table(data3.Time, data3.Var3); % This is a 8065x51 table

% This gives an error of 'must contain same amount of rows.'
S = [s1, s2, s3];

% This puts the three tables into a cell array
S = {s1, s2, s3};

欢迎提出任何建议。

你很接近。你只需要连接你的表 vertically instead of horizontally:

S = [s1; s2; s3];
% Or in functional form
S = vertcat(s1, s2, s3);

请注意,这仅在所有表具有相同数量的变量(即列)时才有效。