When I run my program I outputs a weird error message.

조회 수: 2 (최근 30일)
Hugh
Hugh 2013년 4월 3일
> 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)]);

채택된 답변

Lokesh Ravindranathan
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개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by