Clear Filters
Clear Filters

Error Using textscan Invalid fid

2 views (last 30 days)
JoeTeg
JoeTeg on 22 Feb 2024
Edited: Stephen23 on 22 Feb 2024
Hello,
i have following mistaker in the following part of my Matlab code. The Mistake ist unter de Code separate with dashes. Does someone please know how i can solve the problem?
26 formatSpec = '%*s%s%[^\n\r]';
28 fileID = fopen(filename,'r');
29 dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', 1, 'ReturnOnError', 0);
30 status = fclose(fileID);
------------------------------------------------------------------------------------------------------------------
??? Error using ==> textscan
Invalid fid.
Error in ==> fetchQOI at 29
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', 1, 'ReturnOnError', 0);
Error in ==> read_QOI at 6
motor.fem.results.P_mech = fetchQOI(motor.fem, 'Pmech'); % mean(Pmech(N_Steps/2+1:end));
Error in ==> slottedMachineFEM at 38
motor = read_QOI(motor);
  1 Comment
Stephen23
Stephen23 on 22 Feb 2024
Edited: Stephen23 on 22 Feb 2024
"Does someone please know how i can solve the problem?"
FOPEN a file that exists.
Most commonly the filename is incorrect or the file does not exist in the provided location. Use the 2nd output argument to get information on why FOPEN could not open any file:
[fileID,msg] = fopen(filename,'r');
assert(fileID>0,'%s',msg)
Did you provide the filename with an absolute/relative filepath?

Sign in to comment.

Answers (0)

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Tags

Products


Release

R2007b

Community Treasure Hunt

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

Start Hunting!