1

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?

2
  • 2
    Octave does not have a table class like MATLAB does.
    – sco1
    Nov 29, 2017 at 16:21
  • 1
    One alternative is Andrew Janke’s octave-tablocious package. Jan 22, 2022 at 15:28

2 Answers 2

6

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.

4
  • thanks @gnovice how do I install the dataframe package? I tried pkg install -forge dataframe which did not work...
    – pashute
    Nov 30, 2017 at 7:16
  • 3
    @pashute in what way did it "not work"? Did it throw an error? Does the package not show up when you run pkg list ? Does it not load when you pkg load dataframe ? Nov 30, 2017 at 12:28
  • I write experiment = dataframe('data_test.csv') and get unknown ... dataframe .
    – pashute
    Dec 2, 2017 at 16:07
  • 1
    OK I didn't see the load part in your comment. Thank you @TasosPapastylianou ! After pkg install... I needed to pkg load... and then everything's ok.
    – pashute
    Dec 14, 2017 at 6:44
0

You can install the package Tablicious. It, among other things, contains table data structure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.