展开全部
函数如下
function Num = FindStr(A,Str)
%% 将字符串转成ascii
AscA = abs(A);
%% 统计字母和数字个数
Num.Alphbeta = length(find((AscA>=97 & AscA<=122)|(AscA>=65 & AscA<=90)));
Num.Num = length(find((AscA>=48 & AscA<=57)));
%% 将目标字符串转成ascii值
TarAsc = abs(Str);
for i = 1:length(Str)
Num.Other{i,1} = Str(i);
Num.Other{i,2} = length(find(AscA == TarAsc(i)));
end
Num.Other
演示结果
CC = FindStr('AXYHD jiutr_01213 67890.&&&&&&_^^^^ ①①① $$_@',' _.&^①$@')
ans =
' ' [4]
'_' [3]
'.' [1]
'&' [6]
'^' [4]
'①' [3]
'$' [2]
'@' [1]
CC =
Alphbeta: 10
Num: 10
Other: {8x2 cell}
要是觉得还行的话就采纳吧
function Num = FindStr(A,Str)
%% 将字符串转成ascii
AscA = abs(A);
%% 统计字母和数字个数
Num.Alphbeta = length(find((AscA>=97 & AscA<=122)|(AscA>=65 & AscA<=90)));
Num.Num = length(find((AscA>=48 & AscA<=57)));
%% 将目标字符串转成ascii值
TarAsc = abs(Str);
for i = 1:length(Str)
Num.Other{i,1} = Str(i);
Num.Other{i,2} = length(find(AscA == TarAsc(i)));
end
Num.Other
演示结果
CC = FindStr('AXYHD jiutr_01213 67890.&&&&&&_^^^^ ①①① $$_@',' _.&^①$@')
ans =
' ' [4]
'_' [3]
'.' [1]
'&' [6]
'^' [4]
'①' [3]
'$' [2]
'@' [1]
CC =
Alphbeta: 10
Num: 10
Other: {8x2 cell}
要是觉得还行的话就采纳吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询