When I run my program I outputs a weird error message.
2 次查看(过去 30 天)
显示 更早的评论
> In Woodworth_Hugh_Project2 at 66 \people.soecs.ku.eduWarning: Escape sequence 'e' is not valid. See 'help sprintf' for valid escape sequences.
clear all clc
fullPath=mfilename('fullpath'); curMfile=mfilename();
path=fullPath(1:length(fullPath)-length(curMfile));
fileName='studentRecordsBroken.dat'; outFileName=[path,'copy_','studentRecordsFixed.dat']; emailFileName=[path,'studentEmails.dat'];
str='%s'; int='%i'; float='%f'; nl='\n';
fieldWidth=10;
outStr=['%s',num2str(fieldWidth),'s']; outInt=['%i',num2str(fieldWidth),'i']; outFloat=['%f',num2str(fieldWidth),'f'];
inFile=fopen(fileName, 'r'); outFile=fopen(outFileName, 'w'); emailFile=fopen(emailFileName, 'w');
if (inFile==-1) error('File can not be opened'); else disp([fileName,' has been opened.']); end [fname,count]=fscanf(inFile,str,1); [lname,count]=fscanf(inFile,str,1); [id,count]=fscanf(inFile,int,1); [dept,count]=fscanf(inFile,str,1); [gpa,count]=fscanf(inFile,float,1); [credit,count]=fscanf(inFile,int,1);
itr=1;
while count==1
gpa=gpa+1;
gpaVector(itr)=gpa;
creditVector(itr)=credit;
emailStr=[fname,'.', lname, '.',num2str(id),'.','@',dept,'.edu'];
num2str(emailStr);
[fname,count]=fscanf(inFile,str,1);
[lname,count]=fscanf(inFile,str,1);
[id,count]=fscanf(inFile,int,1);
[dept,count]=fscanf(inFile,str,1);
[gpa,count]=fscanf(inFile,float,1);
[credit,count]=fscanf(inFile,int,1);
fprintf(outFile,outStr,fname);
fprintf(outFile,outStr,lname);
fprintf(outFile,outInt,id);
fprintf(outFile,outStr,dept);
fprintf(outFile,outFloat,gpa);
fprintf(outFile,outInt,credit);
fprintf(emailFileName,outStr,emailStr);
itr=itr+1;
end
gpaAvg = mean(gpa); creditAvg = mean(credit);
disp(['The highest gpa: ', num2str(max(gpa))]); disp(['The lowest gpa: ', num2str(min(gpa))]);
disp(['The highest credits: ', num2str(max(credit))]); disp(['The lowest credits: ', num2str(min(credit))]);
disp(['The average gpa: ', num2str(gpaAvg)]); disp(['The average credits: ', num2str(creditAvg)]);
0 个评论
采纳的回答
Lokesh Ravindranathan
2013-4-3
It s a warning message with an escape sequence which is not ISO standard. I think your file contains these escape sequences.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!