Code failure on recent version of MATLAB
古いコメントを表示
Hello, I wondered if anyone could help me with a piece of code that works perfectly well on MATLAB 2017, but when updating to R2019a, it fails. The particular region where it breaks down is:
formatSpec = '%f%[^\n\r]';
fileID = fopen(filename,'r');
delimiter = {''};
startRow = 2;
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
fclose(fileID);
Retured error states problem with textscan ("Invalid file identifier. Use fopen to generate a valid file identifier"), despite the code working in earlier version.
For background, the script will import a text file (almost always .csv) with arbitrary fluorescent values associated with frequency points, followed by formatting, removal of values if required and plotting etc.
Hope that's enough info and thank you :)
1 件のコメント
Guillaume
2020 年 1 月 28 日
What is the value of filename? Is it an absolute or relative path?
採用された回答
その他の回答 (1 件)
An empty permission string is not supported by the documentation:
fopen(filename,'');
% ^^ Not supported by the FOPEN documentation.
I doubt that it was ever supported. You should use a permission string that follows the documentation.
3 件のコメント
Thomas Bateman-Price
2020 年 1 月 28 日
Guillaume
2020 年 1 月 28 日
Please do answer my question. In particular, if filename is a relative path, is the folder where the data is located the current folder or a folder that is supposed to be on matlab's path?
Thomas Bateman-Price
2020 年 1 月 28 日
カテゴリ
ヘルプ センター および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!