diary_file = tempname();
diary(diary_file);
myFun();
diary('off');
output = fileread(diary_file);
strToSearch = 'variable failed'是否有已知的函数来统计输出文件中字符串的出现情况?
发布于 2013-12-09 14:50:59
只需使用strfind
>>output = 'this sentence is a test sentence';
>>strToSearch = 'sentence';
>>numel(strfind(output,strToSearch))
ans =
2strfind告诉您查找字符串(strToSearch)位于文本(output)中的起始索引;numel告诉您有多少这样的索引。
https://stackoverflow.com/questions/20473390
复制相似问题