将名义数组和数值数组连接到数据集(统计工具箱)
我对编程很陌生,所以如果我误用了一些术语,我提前道歉。
我的问题如下:
我有一个具有唯一国家/地区名称的 142 x 1 标称数据集数组 (CountryList) 和四个包含有关这些国家/地区信息的 142 x 1 数字数组。我想将它们组合成一个 142 x 5 数据集数组“CountryInfo”。下面的示例仅包含我要添加的四个数值数组之一,但我假设如果它适用于其中一个,那么同样适用于更多。
我已经尝试了很多事情,包括
CountryInfo = join(CountryList, Info1, 'Type', 'leftouter')
提示错误
??? Undefined function or method 'join' for input arguments of type 'nominal'.
和
CountryInfo = horzcat(CountryList, Info1)
提示错误
All input arguments must be from the same categorical class.
我认为使用数据集类将允许我连接不同类的数组。
如果以上没有意义,请帮助我更清楚。
非常感谢您的帮助!
I'm quite new to programming, so I apologize in advance in case I misuse some terminology.
My problem is the following:
I have one 142 x 1 nominal dataset array (CountryList) with unique country names and four 142 x 1 numerical arrays that contain infos about these countries. I want to bring them together into a single 142 x 5 dataset array 'CountryInfo'. The examples below only include one of the four numerical arrays I want to add, but I assume that if it works for one, the same applies for more.
I've tried a number of things, including
CountryInfo = join(CountryList, Info1, 'Type', 'leftouter')
which prompte the error
??? Undefined function or method 'join' for input arguments of type 'nominal'.
and
CountryInfo = horzcat(CountryList, Info1)
which prompted the error
All input arguments must be from the same categorical class.
I thought that using dataset class would allow me to concatenate arrays of different classes.
Should the above not make sense, please help me to be more clear.
Thank you very much for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该有效:
This should work:
在 Matlab 中,数组/矩阵仅包含数字,不包含字符串。要混合类型,请使用元胞数组(使用花括号)。
输出:
In Matlab, arrays/matrices contain only numbers and not strings. To mix types use cell arrays (using curly braces).
output: