strcmp returns false on comparing equal cell
Show older comments
Hello, I'm writing an analyzer for logfiles of an filetransferprogram. Therefore I'm reading the logfile line by line, extract the usernick and compare it to a cellarray of usernicks. If the nick is already somewhere in the cellarray it increases a counter for this nick, otherwise the nick is written at the end of the cellarray:
nicks = cell(1);
nicks{1,1}{1}=[];
line = textscan(ulfile,'%s',1,'delimiter','\n'); %reading one line
ul = strfind(line{1,1}{1}, 'uploaded to'); %find place of usernick
tempnick = textscan(line{1,1}{1}(ul:end), '%*s %*s %s',1); %extract usernick
for k=1:length(nicks)
if strcmp(nicks{1,k}{1},tempnick{1,1})
match = k;
else
match = 0;
end
end
This code is iterated over every line within the logfile. The problem now is, that sometimes the strcmp works and sometimes not. In the nicks-cellarray is at the end for example two times the user '[abc]crusso', one time with the counter on 3 and one time with the counter on 5. I even tried it with a 39-digit hash of the usernicks without any result. When I'm comparing the strings afterwards manually, strcmp mostly returns 1 on the same usernicks. I'm absolutely clueless, where the problem might be. Thanks for help in advance. Dante
Accepted Answer
More Answers (0)
Categories
Find more on Entering Commands 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!