简体   繁体   中英

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

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. 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?

The table data type in MATLAB is not yet implemented in 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.

As an alternative, you may want to check out the Dataframe package , which can provide you with similar functionality to a MATLAB table .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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