用于读取文本文件的 Matlab 脚本与 Octave 不兼容
Matlab script for reading a text file is not compatible with Octave
为了从文本文件导入数据,我在 MATLAB 中使用了一个脚本。我想在 Octave 中 运行 相同的脚本,但随后出现错误。
我想阅读的文本文件的摘录如下所示:
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
读取文本文件的代码如下:
filename = 'C:\Users\marci\Desktop\Whosebug\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);
这是我在 Octave 中收到的错误消息。
error: textscan: unrecognized option 'texttype'
error: called from
test at line 35 column 11
有谁知道如何解决这个错误?
texttype
不是 Octave 中 textscan
的公认属性之一,请参阅 https://octave.sourceforge.io/octave/function/textscan.html。
通过查看 MATLAB documentation for textscan
,看起来 texttype
并没有做太多事情:
我建议将其从函数调用中完全删除。它应该可以正常工作。
为了从文本文件导入数据,我在 MATLAB 中使用了一个脚本。我想在 Octave 中 运行 相同的脚本,但随后出现错误。
我想阅读的文本文件的摘录如下所示:
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
读取文本文件的代码如下:
filename = 'C:\Users\marci\Desktop\Whosebug\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);
这是我在 Octave 中收到的错误消息。
error: textscan: unrecognized option 'texttype'
error: called from
test at line 35 column 11
有谁知道如何解决这个错误?
texttype
不是 Octave 中 textscan
的公认属性之一,请参阅 https://octave.sourceforge.io/octave/function/textscan.html。
通过查看 MATLAB documentation for textscan
,看起来 texttype
并没有做太多事情:
我建议将其从函数调用中完全删除。它应该可以正常工作。