从数据集创建合适的
我无法使用 matlab 中的 uitable 从数据集创建表,我需要帮助!问题是:
我创建了一个简单的数据集:
names = {'John'; 'Henri'}
ages = [26; 18];
d1 = dataset({names, 'Name'}, {ages, 'Age'})
然后我尝试使用这些数据创建一个数据集,我写了这一行,
uitable('data',double(d1))
但收到了此错误消息:
??? Error using ==> uitable
Data must be a numeric, logical, or cell array
Error in ==> uitable at 56
thandle = builtin('uitable', varargin{:});
所以我再次尝试,
uitable('data',cellstr(d1))
但收到此错误:
??? Error using ==> dataset.cellstr at 32
Error when converting 'Age' to cell array of strings.
Caused by:
Error using ==> cellstr at 34
Input must be a string.
我无法理解如何我可以从包含数字和字符串条目的数据集创建一个数据集。
有人愿意帮助我吗?
I'm not able to create a table from a dataset using the uitable in matlab and I need help! Here's the problem:
I created a simple dataset :
names = {'John'; 'Henri'}
ages = [26; 18];
d1 = dataset({names, 'Name'}, {ages, 'Age'})
then I'have tried to create a uitable with this data and I wrote this line
uitable('data',double(d1))
but I received this error message:
??? Error using ==> uitable
Data must be a numeric, logical, or cell array
Error in ==> uitable at 56
thandle = builtin('uitable', varargin{:});
So I tried again with
uitable('data',cellstr(d1))
but I got this error:
??? Error using ==> dataset.cellstr at 32
Error when converting 'Age' to cell array of strings.
Caused by:
Error using ==> cellstr at 34
Input must be a string.
I can not understand how I can create a uitable from a dataset with both numeric and strings entries.
Would someone be so kind as to help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些错误是因为您使用的是
uitable
错误。这是一个说明如何执行此操作的最小示例。这应该会给你一个整洁的表格,看起来像这样
编辑
来回答你的问题在下面的评论中,如果您像示例中那样从单元格和数组创建数据集,那么您可以直接将两者组合到单元格中
,并按照上面的步骤进行。如果您已经将
d1
作为数据集(可能不是由您创建的),那么您可以从中创建一个uitable
作为The errors are because you are using the
uitable
incorrectly. Here's a minimal example that illustrates how to do it.This should give you a neat table that looks like this
EDIT
To answer your comment below, if you are creating your dataset from a cell and an array as in your example, then you can directly combine both into a cell as
and proceed as above. If you already have
d1
as a dataset, perhaps not created by you, then you can create auitable
from that as