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

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)

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

Asked:

on 26 Nov 2019

Answered:

on 26 Nov 2019

Community Treasure Hunt

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

Start Hunting!