When I run my program I outputs a weird error message.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
> 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 commentaires
Réponse acceptée
Lokesh Ravindranathan
le 3 Avr 2013
It s a warning message with an escape sequence which is not ISO standard. I think your file contains these escape sequences.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Search Path dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!