括号表达式中的所有表必须具有相同的变量名
All tables in the bracketed expression must have the same variable names
我在应用程序设计器中有两个 editable 数字字段和一个 table;用户可以在这些 editable 字段中输入值,然后按下按钮。然后,将这些值添加到 table。此外,我提供了一个选项来附加一个 excel 文件夹,该文件夹应该有两列以反映 table。
这两个单独工作都很好,但是,如果我手动添加值然后附加一个 excel 文件夹,反之亦然,我会收到以下错误:括号表达式中的所有 tables 必须具有相同的变量名。
处理editable字段的函数:
app.t = app.UITable.Data;
x = app.xvalueEditField.Value;
y = app.yvalueEditField.Value;
nr = table(x, y);
app.UITable.Data = [app.t; nr]; %% error happens here if I attach excel then add manually
app.t = app.UITable.Data;
excel文件夹的功能:
text = readtable([pathname filename], "Sheet",1, 'ReadVariableNames',false);
fl = cellfun(@isnumeric,table2cell(text(1,:)));
if (numel(fl(fl == false)) > 0)
flag = false;
else
flag = true;
end
if (flag)
A = [app.t; text]; %% error happens here if I add manually then attach
app.UITable.Data = A;
app.t = text;
end
注意:这些只是函数的一部分,我在其中尝试组合值
有人可以帮我吗?
谢谢
错误消息告诉您 table
仅允许您在 'VariableNames'
属性匹配时垂直连接 table。这记录在这里:https://www.mathworks.com/help/matlab/ref/vertcat.html#btxzag0-1 .
在您的第一个代码示例中,table nr
将具有变量名称 x
和 y
(派生自您用于构造的基础变量的名称table)。您可以通过以下方式解决该问题:
% force nr to have the same VariableNames as app.t:
nr = table(x, y, 'VariableNames', app.t.Properties.VariableNames);
在第二种情况下,您可以强制 text
具有正确的变量名称,如下所示:
text.Properties.VariableNames = app.t.Properties.VariableNames
我在应用程序设计器中有两个 editable 数字字段和一个 table;用户可以在这些 editable 字段中输入值,然后按下按钮。然后,将这些值添加到 table。此外,我提供了一个选项来附加一个 excel 文件夹,该文件夹应该有两列以反映 table。 这两个单独工作都很好,但是,如果我手动添加值然后附加一个 excel 文件夹,反之亦然,我会收到以下错误:括号表达式中的所有 tables 必须具有相同的变量名。 处理editable字段的函数:
app.t = app.UITable.Data;
x = app.xvalueEditField.Value;
y = app.yvalueEditField.Value;
nr = table(x, y);
app.UITable.Data = [app.t; nr]; %% error happens here if I attach excel then add manually
app.t = app.UITable.Data;
excel文件夹的功能:
text = readtable([pathname filename], "Sheet",1, 'ReadVariableNames',false);
fl = cellfun(@isnumeric,table2cell(text(1,:)));
if (numel(fl(fl == false)) > 0)
flag = false;
else
flag = true;
end
if (flag)
A = [app.t; text]; %% error happens here if I add manually then attach
app.UITable.Data = A;
app.t = text;
end
注意:这些只是函数的一部分,我在其中尝试组合值
有人可以帮我吗?
谢谢
错误消息告诉您 table
仅允许您在 'VariableNames'
属性匹配时垂直连接 table。这记录在这里:https://www.mathworks.com/help/matlab/ref/vertcat.html#btxzag0-1 .
在您的第一个代码示例中,table nr
将具有变量名称 x
和 y
(派生自您用于构造的基础变量的名称table)。您可以通过以下方式解决该问题:
% force nr to have the same VariableNames as app.t:
nr = table(x, y, 'VariableNames', app.t.Properties.VariableNames);
在第二种情况下,您可以强制 text
具有正确的变量名称,如下所示:
text.Properties.VariableNames = app.t.Properties.VariableNames