2

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 Answers 2

5

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.

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

2 Comments

Thanks a lot, with your help I was able to replace the functions. Unfortunately another error occurs now concerning a 'dimension mismatch' which I am not able to solve by myself.. I guess I have to post a new question for that? I just ask because I am new to Stack Overflow and do not know exactly how it is handled here.
Glad I could help, yep that sounds like a new question :)
1

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

1 Comment

Link-only answers are usually better suited as comments under the question. This could be improved by showing how the package could actually be used in the context of this question.

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.