Error: File: Expression or statement is incorrect--possibly unbalanced (, {, or [

2 次查看(过去 30 天)
fprintf(fid3,'%d \t %f \t %f \t %s \n',person,faceweight, fpweight,str1);
  2 个评论
faaruuq jamaludin
编辑:Stephen23 2018-3-8
the full code
V% Open files with face score and fingerprint score
fid1=fopen('finalfacescore1.txt','r');
fid2=fopen('finalfpscore1.txt','r');
fid3=fopen('weightdatabase1.txt','wt+');
facescore = [];
fpscore = [];
fcount=1;
count=100;
tscore=0.0;
success=0;
failure=0;
faceweight=0.9;
fpweight=0.1;
%fetch face score and fingerprint score in array
facescore=fscanf(fid1,'%f',900);
fpscore=fscanf(fid2,'%f',900);
% first loop for 30 persons
for i=1:30
maxscore=0;
person=count+i;
totalscore = [];
index=0;
tempface = [];
tempfp = [];
faceweight=0.9;
fpweight=0.1;
% second loop for each person's score comparison
for j=1:30
tempface = [tempface facescore(fcount)];
tempfp = [tempfp fpscore(fcount)];
fcount=fcount+1;
end
k=1;
% loop will go for nine times for nine different score
combinations. If
% person matches with index than success else failure and loop will
% stop on finding success.
while(k<=9)
%call identifyperson function to get mathcing index
[index]=identifyperson(person,faceweight,fpweight,tempface,tempfp);
if(person==index)
fprintf(['in success \n']);
success=success+1;
str1='success';
fprintf(fid3,'%d \t %f \t %f \t %s \n',person,faceweight, fpweight,str1);
break;
else
fprintf(['in failure\n']);
failure=failure+1;
%on failure in matching person with index weights are adjusted.
%fpweight is increased by 0.1 and faceweight decreased by 0.1
[fp,fw]=adjustweight(faceweight,fpweight);
k=k+1;
faceweight=fp;
fpweight=fw;
if(k==10)
str1='failure';
fprintf(fid3,'%d \t %f \t %f \t %s \n', person,
faceweight, fpweight,str1);
fprintf(['Failure to identify \n']);
end
end
end
end
%calculate success rate
successrate=(success/30)*100;
fprintf(['Successful identification :' num2str(success) '\n']);
str2='successrate=';
%write success rate in file
fprintf(fid3,'%s \t %f \n',str2,successrate);
fclose(fid1);
fclose(fid2);
fclose(fid3);
Stephen23
Stephen23 2018-3-8
@faaruuq jamaludin: Your code is badly aligned. Badly aligned code is one way that beginners hide mistakes and bugs in their code. You should use the default alignment of the MATLAB editor: select all code, the press ctrl+i.

请先登录,再进行评论。

采纳的回答

Stephen23
Stephen23 2018-3-8
fprintf(fid3,'%d \t %f \t %f \t %s \n', person, faceweight, fpweight,str1);
or
fprintf(fid3,'%d \t %f \t %f \t %s \n', person, ...
faceweight, fpweight,str1);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by