2
votes

I want to run my MATLAB script in Octave but have problems with the table function which does not yet exist in Octave.

An extract of the table that I want to work with looks as follows:

Rotation angle  Measured distance
-0,342  0,000
-1,440  0,000
-10,422 0,000
-11,574 0,000
-21,060 0,000
-21,528 0,000
-30,402 0,000

To create my output variable I am using the following code in MATLAB.

data = table;
data.Rotationangle = cell2mat(raw(:, 1));
data.Measureddistance = cell2mat(raw(:, 2));

In Octave I get the following error then.

warning: the 'table' function is not yet implemented in Octave

Please read <https://www.octave.org/missing.html> to learn how you can
contribute missing functionality.
error: 'table' undefined near line 102 column 8
error: called from
    Cloud_reconstruction at line 102 column 6

My question is now, is there any opportunity to replace the table function in Octave? I tried to find a solution with Octave data frame package but was not really able to.

In the same script I am also using the table2array function which is also not yet implemented in Octave and will later occur an error as well.

data = table2array(data); 

I would be glad if someone could help me with that.

2

2 Answers

5
votes

You can use similar syntax for "column" indexing with a struct

data = struct;
data.var1 = [1;2;3;4];
data.var2 = [5;6;7;8];

However, you lose a lot of the table-specific operations available in MATLAB.

If you've got the above data, you can use struct2array instead of table2array for your conversion to a matrix

data = struct2array( data );

If you are using table2array anyway, you'll end up with a matrix, so why not just stick to matrices in the first place? If all of your data is numeric, they will be generally faster to operate on.

data = [cell2mat(raw(:,1)), cell2mat(raw(:,2))];

Edit: it appears struct2array may also be missing from Octave. However, in that missing link you can find several attachments for equivalent functions.

0
votes

I invite you to try my Tablicious package, which provides a Matlab-compatible Octave implementation of table, datetime, and related classes.

https://github.com/apjanke/octave-tablicious