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?

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
pashute
  • 3,965
  • 3
  • 38
  • 65

2 Answers2

5

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.

gnovice
  • 125,304
  • 15
  • 256
  • 359
  • thanks @gnovice how do I install the dataframe package? I tried `pkg install -forge dataframe` which did not work... – pashute Nov 30 '17 at 07: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` ? – Tasos Papastylianou Nov 30 '17 at 12:28
  • I write `experiment = dataframe('data_test.csv')` and get `unknown ... dataframe` . – pashute Dec 02 '17 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 '17 at 06:44
0

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

rahnema1
  • 15,264
  • 3
  • 15
  • 27