简体   繁体   English

如何在 octave 中使用 matlab 表(带有命名变量的数组)

[英]How can I use matlab table (array with named variables) in octave

In Octave I code:在八度我编码:

T = table([10;20],{'M';'F'},'VariableNames',{'Age','Gender'},'RowNames',{'P1','P2'})

From the example on this website: https://www.mathworks.com/help/matlab/ref/table.html来自本网站上的示例: https ://www.mathworks.com/help/matlab/ref/table.html

And get error:并得到错误:

't' undefined near line 1 column 1
>> [T, L_X] = table([10;20],{'M';'F'},'VariableNames',{'Age','Gender'},'RowNames',{'P1','P2'})
error: Invalid call to table.  Correct usage is:
-- [T, L_X] = table (X)

But when I change to [T, L_X] = ... or to [T, L_X, L_Y] = ... I get the same error.但是当我更改为[T, L_X] = ...或更改为[T, L_X, L_Y] = ...我得到同样的错误。 What am I doing wrong and what am I misunderstanding?我做错了什么,我误解了什么? What should I do to get the example right?我应该怎么做才能使示例正确? Is this an issue of Matlab/Octave differences?这是 Matlab/Octave 差异的问题吗?

The table data type in MATLAB is not yet implemented in Octave. MATLAB 中的table数据类型尚未在 Octave 中实现。 There is a table function in Octave for creating a contingency table, which is what your code is using, and is obviously not what you want. Octave 中有一个用于创建列联表的table函数,这是您的代码正在使用的,显然不是您想要的。

As an alternative, you may want to check out the Dataframe package , which can provide you with similar functionality to a MATLAB table .作为替代方案,您可能需要查看Dataframe 包,它可以为您提供与 MATLAB table类似的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM