Error Using textscan Invalid fid

2 次查看(过去 30 天)
JoeTeg
JoeTeg 2024-2-22
编辑: Stephen23 2024-2-22
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 个评论
Stephen23
Stephen23 2024-2-22
编辑:Stephen23 2024-2-22
"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?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

标签

产品


版本

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by