2013-12-09 2 views
0
diary_file = tempname(); 
diary(diary_file);   
myFun(); 
diary('off');    
output = fileread(diary_file); 

strToSearch = 'variable failed' 

출력 파일에서 문자열의 발생을 계산하는 알려진 함수가 있습니까?카운트 출력에서 ​​문자열 발생 수 MATLAB

>>output = 'this sentence is a test sentence'; 
>>strToSearch = 'sentence'; 
>>numel(strfind(output,strToSearch)) 
ans = 
    2 

strfind 당신에게 추구 문자열 (strToSearch가) 텍스트 (output) 내에있는 시작하는 인덱스를 말한다;

답변

0

그냥 strfind 사용 numel은 그러한 색인이 몇 개인 지 알려줍니다.