Hello I try to run a matlab code for my data analysis and in the first step I get this error: Error using textscan

3 views (last 30 days)
In one compiuter this code works well but in other not.
Error using textscan
Invalid file identifier. Use fopen to generate a valid identifier.

Answers (1)

Walter Roberson
Walter Roberson on 26 Nov 2019
That tells you that the file name you passed into fopen() could not be found or was unreadable. This is not a textscan() issue: this is because you failed to check the return of fopen() in case of failure.
filename = 'TheFileNameGoesHere';
[fid, msg] = fopen(filename, 'rt');
if fid < 0
error('Failed to open file "%s" because "%s"', filename, msg);
end

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!