Code failure on recent version of MATLAB
Mostrar comentarios más antiguos
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 comentario
Guillaume
el 28 de En. de 2020
What is the value of filename? Is it an absolute or relative path?
Respuesta aceptada
Más respuestas (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 comentarios
Thomas Bateman-Price
el 28 de En. de 2020
Guillaume
el 28 de En. de 2020
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
el 28 de En. de 2020
Categorías
Más información sobre Text Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!