Marc
Marc

Reputation: 51

Matlab script for reading a text file is not compatible with Octave

To import data from a text file I use a script in MATLAB. I want to run the same script in Octave but then I get an error.

An extract of the text file that I want to read 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

The following code is reading the text file:

filename = 'C:\Users\marci\Desktop\Stackoverflow\S4P1_Logfile_160419_1345.txt';   
delimiter = '\t';
startRow = 3;
formatSpec = '%s%s%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
fclose(fileID);

That is the error message that I get in Octave.

error: textscan: unrecognized option 'texttype'
error: called from
    test at line 35 column 11

Does anyone know how to fix this error?

Upvotes: 0

Views: 289

Answers (1)

am304
am304

Reputation: 13876

texttype is not one of the recognized properties for textscan in Octave, see https://octave.sourceforge.io/octave/function/textscan.html.

By looking at the MATLAB documentation for textscan, it looks like texttype doesn't do much anyway:

enter image description here

I would suggest removing it altogether from the function call. It should just work.

Upvotes: 1

Related Questions