Error using feof, Invalid file identifier. Use fopen to generate a valid file identifier.

23 views (last 30 days)
fin = fopen('mcs_ansys_standard.txt','rt');
fout = fopen('mcs_ansys.txt','wt');
while ~feof(fin);
str = fgetl(fin);
if strncmp(str,'F,P51X,FY,-',length('F,P51X,FY,-'));
str =strcat('F,P51X,FY,-',num2str(P));
elseif strncmp(str,'MPDATA,EX,1,,',length('MPDATA,EX,1,,'));
str =strcat('MPDATA,EX,1,,',num2str(E));
elseif strncmp(str,'SFBEAM,P51X,1,PRES,',length('SFBEAM,P51X,1,PRES,'));
str =strcat('SFBEAM,P51X,1,PRES,',num2str(W));
end
fprintf(fout, '%s\r\n', str);
end
fclose(fin);
fclose(fout);
!"C:\Program Files\ANSYS Inc\v150\ANSYS\bin\winx64\ansys150.exe" -p ansys -dir "C:\Users\Sirisha\Documents\MATLAB\ranjith" -j "MCS_FEA" -dvt -s read -l en-us -b -i "C:\Users\Sirisha\Documents\MATLAB\ranjith\mcs_ansys.txt" -o "C:\Users\Sirisha\Documents\MATLAB\ranjith\deflecion_out.txt"
fid = fopen('del_max.out','rt');
flag_string = 'NODE UY';
while ~feof(fid);
s = fgets(fid);
flag = strfind(s,flag_string);
if flag
s1 = fgets(fid);
s2 = fgets(fid);
s3 = fgets(fid);
break
end
end
s = str2num(strtrim(s2));
deflection(i) = -s(2);
fclose('all');
end

Answers (1)

Walter Roberson
Walter Roberson on 25 Mar 2016
mcs_ansys_standard.txt could not be found on the MATLAB path. It either does not exist at all, or is in some directory that is not on the MATLAB path.

Categories

Find more on RF Toolbox 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!