0001 function out=isTradChinese(string, chineseCharAll)
0002
0003
0004
0005
0006
0007 if nargin<1, selfdemo; return; end
0008 if nargin<2, chineseCharAll=fileread('chineseChar.txt'); end
0009
0010 strLen=length(string);
0011 out=zeros(strLen, 1);
0012 for i=1:strLen
0013 index=find(chineseCharAll==string(i));
0014 if length(index)>0
0015 out(i)=1;
0016 end
0017 end
0018 out=logical(out);
0019
0020
0021 function selfdemo
0022 string='Roger的年紀已經大於40歲';
0023 output=isTradChinese(string);
0024 fprintf('input = %s\n', string);
0025 fprintf('output = %s\n', mat2str(output));