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. Commented Nov 29, 2017 at 16:21
  • 1
    One alternative is Andrew Janke’s octave-tablocious package. Commented 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.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks @gnovice how do I install the dataframe package? I tried pkg install -forge dataframe which did not work...
@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 ?
I write experiment = dataframe('data_test.csv') and get unknown ... dataframe .
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.
0

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.