Code failure on recent version of MATLAB
Afficher commentaires plus anciens
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 commentaire
Guillaume
le 28 Jan 2020
What is the value of filename? Is it an absolute or relative path?
Réponse acceptée
Plus de réponses (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 commentaires
Thomas Bateman-Price
le 28 Jan 2020
Guillaume
le 28 Jan 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
le 28 Jan 2020
Catégories
En savoir plus sur Text Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!